※ 引述《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