在这里处理一个SQL查询,我有一个我创建的ID列,我希望能够获取最大ID号并在其后面显示12。见图。我想显示第20行第8行以及8以上的所有内容。有人可以通过订单或声明来帮助我吗?
由于
我的SQL查询:
SELECT TOP(100)PERCENT ROW_NUMBER()OVER(按FiscalYear,FiscalMonth排序)为ID,FiscalYear,FiscalMonth,SUM(STDCOST)AS STDCost,Concat 来自dbo。[13568] GROUP BY FiscalYear,FiscalMonth,Concat 按FiscalYear,FiscalMonth排序
答案 0 :(得分:1)
我错过了什么吗?
SELECT * FROM (
SELECT TOP 13 ROW_NUMBER() OVER (ORDER BY FiscalYear, FiscalMonth) as ID
,FiscalYear
,FiscalMonth
,SUM(STDCOST) AS STDCost
,Concat
FROM dbo.[13568]
GROUP BY FiscalYear, FiscalMonth, Concat
ORDER BY FiscalYear DESC, FiscalMonth DESC
) AS X
ORDER BY FiscalYear, FiscalMonth