私のアプリケーションでは、私はちょうど取得したかったnumber of sales in a day by diiferent time interval
お気に入り
-----------------------------------------------------
Interval | Count
-----------------------------------------------------
00:30 to 0:130 | 3
01:30 to 10:30 | 4
02:30 to 03:30 | 5
..
..
12:30 to 00:30 | 10
-----------------------------------------------------
次のようなクエリを試しました
select '00:30 to 01:30' as intrval , COUNT(*) AS 'count' from Pharmacy.tblSalesHdr SH
where CAST(SH.created_Date AS TIME) BETWEEN '00:30' AND '00:30'
UNION ALL
select '01:30 to 02:30' as intrval , COUNT(*) AS 'count' from Pharmacy.tblSalesHdr SH
where CAST(SH.created_Date AS TIME) BETWEEN '01:30' AND '02:30'
UNION ALL
select '02:30 to 03:30' as intrval , COUNT(*) AS 'count' from Pharmacy.tblSalesHdr SH
where CAST(SH.created_Date AS TIME) BETWEEN '02:30' AND '03:30'
and so on...
better and optimized method
これを達成するためにそこに何かあるかどうかを知りたいだけです。誰かがplsシェアを知っているなら。