作者bcse (Lvx ex Caelis)
看板Database
标题Re: [SQL ] 想要查询各笔资料的数目和总和
时间Sat Sep 15 12:59:59 2007
※ 引述《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