看板 Database 關於我們 聯絡資訊
之前有寫過類似的 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
joedenkidd:已解決, 把過濾條件放在count就可以了!! 02/27 12:12