※ 引述《diamondking (天劍流星)》之銘言:
: ※ 引述《JYHuang (夏天到了,冷不起來了說)》之銘言:
: : 其本上是分兩次查詢就可以完成
: : select count(*) from table
: : select count(*) from table where xxx group by xx
: : 那要怎麼一次查詢就把兩種資料取出來呢?
: 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數
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 220.130.230.7