作者JYHuang (夏天到了,冷不起来了说)
看板Database
标题Re: [SQL ] 想要查询各笔资料的数目和总和
时间Sat Sep 15 12:29:24 2007
※ 引述《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