I have the following table named Orders:
MerchantID (INT)
OrderID (VARCHAR2)
OrderAmount (INT)
CreatedDate (DATE/TIME)
I need to create a query that returns the average amount of orders per hour in the last X days per merchant.
Trying with:
SQL>
SELECT CAST(Startdate as CreatedDate) as 'StartDate',
CAST(DATEPART(Hour, StartDate) as varchar) + ':00' as 'Hour',
AVG(OrderAmount) as 'Average_OrderAmounts'
FROM ORDERS
GROUP BY CAST(Startdate as CreatedDate), DATEPART(Hour, StartDate)
ORDER BY CAST(Startdate as CreatedDate) ASC
does result in 0 results and I am not sure where is wrong.