Friday, August 10, 2012

SQL Query to return 24 hour


SELECT CONVERT(VARCHAR(10),hd.Cleared_Date_Time,101) as dDate, CONVERT(VARCHAR(2),hd.Cleared_Date_Time,108) as TDate,
COUNT(hd.delivery_id) AS TotalHourlyTransactions
FROM hose_delivery hd , hoses h , grades g WITH (NOLOCK)
WHERE hd.hose_id = h.hose_id and h.grade_id = g.grade_id AND
hd.Cleared_Date_Time BETWEEN CAST('08-08-2012' AS SMALLDATETIME) AND CAST('09-08-2012' AS SMALLDATETIME)
GROUP BY CONVERT(VARCHAR(10),hd.Cleared_Date_Time,101), CONVERT(VARCHAR(2),hd.Cleared_Date_Time,108)
ORDER BY TDate ASC

No comments: