表結構
SQL語句:
--sql語句,根據時間分組查詢,因爲我數據庫存儲的時間戳所以使用from_unixtime函數
select from_unixtime(sw_startTime, '%Y-%m-%d') 日期,count(if(sw_guestMsg=1,sw_guestMsg,NULL)) 1句話,count(if(sw_guestMsg=2,sw_guestMsg,NULL)) 2句話,count(if(sw_guestMsg=3,sw_guestMsg,NULL)) 3句話 from sem_swt group by from_unixtime(sw_startTime,'%Y-%m-%d');
結果(根據時間分組查詢):