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

1 comment

Please sign in to leave a comment.

Didn't find what you were looking for?

New post