按日期ORDERING的Sql GROUP [英] Sql GROUP by ORDERING by DATE

查看:84
本文介绍了按日期ORDERING的Sql GROUP的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要在这里通过DATEREPORTED订购:



I NEED TO ORDER BY THE DATEREPORTED HERE:

SELECT        b.Client,a.Claim,CAST( a.DateReported AS dATE)AS [DATE], c.Parameter18
FROM            dbo.Claim a INNER JOIN
                         dbo.Client b ON a.Client = b.Client INNER JOIN
                         dbo.ClaimSupplement c ON a.Claim = c.Claim
						 Where Master=50
						 and a.DateReported between '3/1/16' and '6/30/16'
						 GROUP BY CAST( a.DateReported AS dATE)
						ORDER BY a.DateReported





我收到以下错误消息:



I get the following error message:

Msg 8120, Level 16, State 1, Line 1
Column 'dbo.Client.Client' is invalid in the select list because it is not contained in either an aggregate function or the GROUP BY clause.







如何通过datereported修改我的quiery to group?谢谢



我尝试过:






how do I modify my quiery to group by datereported? Thank you

What I have tried:

SELECT        b.Client,a.Claim,CAST( a.DateReported AS dATE)AS [DATE], c.Parameter18
FROM            dbo.Claim a INNER JOIN
                         dbo.Client b ON a.Client = b.Client INNER JOIN
                         dbo.ClaimSupplement c ON a.Claim = c.Claim
						 Where Master=50
						 and a.DateReported between '3/1/16' and '6/30/16'
						 GROUP BY CAST( a.DateReported AS dATE)
						ORDER BY a.DateReported

推荐答案

我们可以'我真的回答这个问题,因为我们不知道你要对你的分组做什么。

看看这个: [ ^ ] - 它可以帮助你理解wh错误就是说。
We can't really answer that, because we don't know what you are trying to do with your groupings.
Have a look at this: SQL GROUP By and the "Column 'name' is invalid in the select list because..." error[^] - it may help you understand what the error is saying.


试试这个

try this
SELECT        b.Client,a.Claim,CAST( a.DateReported AS dATE)AS [DATE], c.Parameter18
FROM            dbo.Claim a INNER JOIN
                         dbo.Client b ON a.Client = b.Client INNER JOIN
                         dbo.ClaimSupplement c ON a.Claim = c.Claim
						 Where Master=50
						 and a.DateReported between '3/1/16' and '6/30/16'
						 
						ORDER BY CAST( a.DateReported AS dATE)


这篇关于按日期ORDERING的Sql GROUP的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆