Custom Report Help - Last Order No

Why are you using ticket tags to separate departments instead of using departments? You would have to redefine all standard reports. Also why are you trying to get the last order in a report, I would think thats generally needed for some sort of recall not a report.

If you were able to use departments for this SQL would be the way to go. You can easily get the last order based on department and limit it to a single result. Such as:

SELECT Top 1	Orders.CreatedDateTime, Orders.OrderNumber
FROM            Orders INNER JOIN
                         Departments ON Orders.DepartmentId = Departments.Id
WHERE Departments.Name = 'Cafe'
ORDER BY Orders.Id DESC 

Then use {REPORT SQL DETAILS:<handler or sql>;<parameters,1,2>:<fields>:<expressions>:<format>} to define what you’re looking to get in your report.

See:

1 Like