Re: [SQL ] 想要查詢各筆資料的數目和總和

看板Database (資料庫)作者 (Lvx ex Caelis)時間18年前 (2007/09/15 13:00), 編輯推噓0(000)
留言0則, 0人參與, 最新討論串6/6 (看更多)
※ 引述《JYHuang (夏天到了,冷不起來了說)》之銘言: : ※ 引述《diamondking (天劍流星)》之銘言: : : select a.*, (select count(1) from table) from : : ( : : select id, count(1) from table where .... group by id : : ) : : 如此即可 : MySQL似乎不支援這種方法 @@ : Every derived table must have its own alias : 詳述一下需求好了,用的是MySQL : 有一個v_count table裡面有year,month,day,count四個欄位 : 我想一次取出,指定時間(年或月)內的count總和 : 和其間內時段(月或日)的各別count數 select a.*, (select count(1) from table) from ( select id, count(1) from table where .... group by id ) as aaaaa 這樣應該就可以了 -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 59.115.217.158
文章代碼(AID): #16wsRGzA (Database)
文章代碼(AID): #16wsRGzA (Database)