Q:

MySQL get start and end date of a quarter by quarter number

$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)";

Given only current years rows count, because grouping by quarter, I need to group by (quarter,year), how can I do that?

A:

If you need to group by quarter and year - just do so:
GROUP BY YEAR(last_call), QUARTER(last_call)

