Payments by Terminal Report

###@@PaymentsByDepartment

select 
    PT.Name,
    Convert(nvarchar,Cast(sum(Amount) as Money),1) as Amount
  from payments
  inner join PaymentTypes as PT on PT.Id = PaymentTypeId
  where DepartmentId in (select id from Departments where Name = '@1') 
     and Date > '{Start}' and Date < '{End}'
group by PT.Name

###Template

[Payments by Department:1, 1]
>Restaurant|
@@PaymentsByDepartment:Restaurant

>Delivery|
@@PaymentsByDepartment:Delivery

It displays report for two departments named Restaurant and Delivery. You can change these departments by changing @@PaymentsByDepartment:Restaurant part to your department name. Also don’t forget to change headers by changing >Restaurant| line.

This sql script also demonstrate how to format amounts by thousand separators.

###Database Tools Import File

Payments by Department.zip (670 Bytes)

1 Like