获取最大计数值

  • 本文关键字:获取 sql sql-server
  • 更新时间 :
  • 英文 :

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

相关内容

  • 没有找到相关文章