【求助】SqlServer嵌套查询报错
发布网友
发布时间:2022-04-10 02:24
我来回答
共2个回答
热心网友
时间:2022-04-10 03:54
子查询中不能有order by ,除非子程序包括了top 子句,可以这样改:
SELECT TOP 10 *
FROM
(SELECT [查询月份]
,[结算账号]
,折后RMB=SUM([本月折后金额RMB])
FROM [Customer].[dbo].[月结客户消费金额趋势报表]
WHERE [ [查询月份] BETWEEN 201501 AND 201506
GROUP BY [查询月份] ,[结算账号]) AS AAAAAA
ORDER BY [查询月份] ,[结算账号]
或者:
SELECT top 10 [查询月份]
,[结算账号]
,折后RMB=SUM([本月折后金额RMB])
FROM [Customer].[dbo].[月结客户消费金额趋势报表]
WHERE [ [查询月份] BETWEEN 201501 AND 201506
GROUP BY [查询月份] ,[结算账号]
ORDER BY [查询月份] ,[结算账号]
热心网友
时间:2022-04-10 05:12
子查询中只能返回一条记录