求教sql 嵌套查询总是提示错误
答案:1 悬赏:50 手机版
解决时间 2021-03-29 11:31
- 提问者网友:战皆罪
- 2021-03-28 12:51
求教sql 嵌套查询总是提示错误
最佳答案
- 五星知识达人网友:蕴藏春秋
- 2021-03-28 13:52
子查询中不能有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 [查询月份] ,[结算账号]
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 [查询月份] ,[结算账号]
我要举报
如以上问答信息为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
大家都在看
推荐资讯