我有我所screenshotted並上傳此圖片的表:編寫特定的SQL集團By語句
我需要創建一個SQL查詢,計算的訂單數量與以下比薩餅數量:1,2,3,4,5,6和以上6.
我試過一些SQL語句,但沒有找到正確的。
我現在的嘗試是
<asp:SqlDataSource ID="SqlDataSource1" runat="server"
ConnectionString="<%$ ConnectionStrings:ConnectPizza %>"
SelectCommand="Select '1' AS Caption, Count(quantity) AS Count FROM orders WHERE quantity = 1
UNION ALL
Select '2' AS Caption, Count(quantity) AS Count FROM orders WHERE quantity = 2
UNION ALL
Select '3' AS Caption, Count(quantity) AS Count FROM orders WHERE quantity = 3
UNION ALL
Select '4' AS Caption, Count(quantity) AS Count FROM orders WHERE quantity = 4
UNION ALL
Select '5' AS Caption, Count(quantity) AS Count FROM orders WHERE quantity = 5
UNION ALL
Select '6' AS Caption, Count(quantity) AS Count FROM orders WHERE quantity = 6
UNION ALL
Select 'Above 7' AS Caption, Count(quantity) AS Count FROM orders WHERE quantity > 7">
</asp:SqlDataSource>
,但它是不會成功的。
我也想做一個圖表,但即使我的sql語句成功了,我也不確定我會爲我的X和Y值成員輸入什麼內容。
任何幫助,將不勝感激。
你期望輸出什麼? – Arion 2014-10-08 06:55:45
又一個**非ASP經典**問題,''
Lankymart
2014-10-08 07:56:02