SELECT YEAR(BL.[Issued]) AS Year,
BL.[Category] as Category,
COUNT(BL.[Licence No#]) as LicenceIssued
FROM [dbo].[businesslicences$] BL
WHERE BL.[Category] = 'PERSONAL SERVICES SETTINGS'
AND YEAR(BL.[Issued]) > 2015
GROUP BY BL.[Category],
YEAR(BL.[Issued])
ORDER BY COUNT(BL.[Licence No#]) DESC
LIMIT 1
我想要得到最大值。LIMIT 1
不工作
代替limit use top for SQL server
SELECT top 1 YEAR(BL.[Issued]) AS Year, BL.[Category] as Category, COUNT(BL.[Licence No#]) as LicenceIssued
from [dbo].[businesslicences$] BL
WHERE BL.[Category]='PERSONAL SERVICES SETTINGS' AND YEAR(BL.[Issued])>2015
GROUP BY BL.[Category], YEAR(BL.[Issued])
ORDER BY COUNT(BL.[Licence No#]) DESC