Top sales report by group

Hi Everyone,

currently using the below query to generate top sales report, we have drinks and food custom tag. Can anyone help how to split the report top 20 for food and top 20 for drinks>?

[Top 20 Best Sellers Orders:1, 1]
>Item Name|Total
{REPORT SQL DETAILS:
   SELECT Top 20 MenuItemName,Sum(Price*Quantity) as Amount FROM ORDERS
   Where CreatedDateTime > '{Start}' and CreatedDateTime < '{End}'
   Group by MenuItemName
   Order by Amount desc:
F.MenuItemName,F.Amount}

Set your Tag field to Food and Drinks. Custom Tags are stored in JSON

{REPORT SQL DETAILS:
   SELECT Top 20 MenuItemName,Sum(Price*Quantity) as Amount FROM ORDERS O
       INNER JOIN MenuItems MI ON 
                  O.MenuItemId = MI.Id
   Where
       CreatedDateTime BETWEEN '{Start}' AND '{END}'
          AND
       MI.Tag = 'Food'
   Group by MenuItemName
   Order by Amount desc:
F.MenuItemName,F.Amount}
1 Like

Thank You So Much. This really helps.

I have added(DRINKS,FOOD) in the tag as below

and manage to generate the report as below
image

1 Like