作者joedenkidd (优质的蓝色射手)
看板Database
标题Re: [SQL ] 栏位合并查寻问题
时间Wed Feb 26 20:49:30 2014
之前有写过类似的
select product,count(1),count(case when tag='1' then '1' else null end) as a_row from
a_table where date(date) between date(昨天) and date(今天) group by product;
但这次因为时间跟日期分开,就不知道如何下手了
: 我现在遇到一个问题, 我要 查前一天下午三点到今天11点资料,然後计算总数
: select sum(1) from (
: select * from table where (date(date_1)=date(昨天日期) and time_1>'15:00:00')
: union
: select * from tabltable where (date(date_1)=date(今天日期) and time_1<'11:00:00'))
--
※ 发信站: 批踢踢实业坊(ptt.cc)
◆ From: 114.44.1.224
1F:→ joedenkidd:已解决, 把过滤条件放在count就可以了!! 02/27 12:12