MySQL获得季度数字的开始和结束日期

时间:2011-05-20 10:38:09

标签: mysql

$sq ="
SELECT count(noofrows),QUARTER(Date(last_call)) as quarter,YEAR(last_call) 
FROM $dbt.travel_crm 
WHERE Date(last_call) BETWEEN '".$_GET['startdate']."' 
AND '".$_GET['enddate']."' 
GROUP BY QUARTER(Date(last_call)) 
ORDER BY YEAR(last_call)";

只考虑当前年份的行数,因为按季度分组,我需要按(quarter,year)进行分组,我该怎么做?

1 个答案:

答案 0 :(得分:2)

如果您需要按季度和年份分组 - 只需这样做:

GROUP BY YEAR(last_call), QUARTER(last_call)