我想先按月订购,然后按月订购。这就是我的查询现在的样子:
select DATE_FORMAT(`Datum Bezoek 1`, '%e %M') AS `DATE`, sum(GoedkeuringDoorNew = 'GF') + sum(GoedkeuringDoorNew = 'SB') + sum(GoedkeuringDoorNew = 'VIA') AS PA, sum(PB = 1) AS PB, sum(PG = 1) AS PG, sum(GoedkeuringDoorNew = 'GF') AS GF, sum(GoedkeuringDoorNew = 'SB') AS SB, sum(GoedkeuringDoorNew = 'VIA') AS VIA, sum(Blanco = 1) AS Blanco, `Segment No_ PST` AS Segment, Deelgebied AS Area
from `psttodo-uit`
where `Hostess Code` = 010 and DATE(`afgewerkt tablet datum`) BETWEEN STR_TO_DATE('2014-05-01', '%Y-%m-%d') AND STR_TO_DATE('2014-06-20', '%Y-%m-%d')
group by DATE_FORMAT(`Datum Bezoek 1`, '%e %M'), Deelgebied
order by DATE_FORMAT(`Datum Bezoek 1`, '%e %M')
但我的结果现在看起来像这样:
10 June
10 June
12 June
12 May
12 May
13 June
13 May
如何确保结果如下:
12 May
12 May
13 May
10 June
10 June
12 June
13 June
我试过这样做:
order by MONTH(DATE_FORMAT(`Datum Bezoek 1`, '%e %M')), DAYOFMONTH(DATE_FORMAT(`Datum Bezoek 1`, '%e %M'))
但结果却更为复杂。