SQL Query - Order Revenue Totals and Order Count Totals
0
I got to thinking, what are some useful queries we could share here?
Here's a simple query to find the Order Totals for a specific timeframe and sums it up.
SELECT SUM (OT.SubTotal) AS TotalRevenue
FROM ORD_OrderTotals OT
JOIN ORD_Order O ON O.recordnumber = OT.OrderNumber
WHERE O.CommissionDate IS NOT NULL AND O.OrderDate >= '2019-12-01' AND O.OrderDate < '2020-01-01'
Here's a similar one for Order Count Totals, for a specific timeframe.
SELECT COUNT (OT.OrderNumber) AS TotalOrders
FROM ORD_OrderTotals OT
JOIN ORD_Order O ON O.recordnumber = OT.OrderNumber
WHERE O.CommissionDate IS NOT NULL AND O.OrderDate >= '2019-12-01' AND O.OrderDate < '2020-01-01'
Comments
Thanks, Ellison, this is good stuff. There's another collection of SQL queries in this article: https://help.directscale.com/hc/en-us/articles/360037859394?page=1#comment_360004146693
Please sign in to leave a comment.