Reputation: 681
I have run across a query where the developer is using the same alias twice in the query.
This was done several times in the Query- so I don't think it was a mistake. Is there a reason to do this that I am not aware of or, is it just sloppy work?
(Select
AppointmentID
,Division
,Hospital
,ApptDate
,KeptDate
From
(Select
s1.AppointmentID
,s1.Division
,s1.Hospital
,s1.Apptdate
,s1.KeptDate
From S1
Group By
s1.AppontmentID
,s1.Division
,s1.Hospital
,s1.Apptdate
,s1.KeptDate) as S2
Group By
AppointmentID
,Division
,Hospital
,ApptDate
,KeptDate) As S2
This is the code simplified down- there are many more fields but no aggregate in them as well as the fact that both Group Bys follow one after the other. There is nothing in between them.
Thanks,
Upvotes: 2
Views: 513
Reputation: 6999
MIN/MAX/AVG
etc.)AppointmentID
) is in the aggregation, it makes it useless (is it unique?) if it is unique, this will return the same result as a simple SELECT
statmentUpvotes: 1
Reputation: 13725
If you strip down the external query you will get the same result. So this is sloppy work in this form. But is you removed something important to simplify the example it can be a cause. (for example joined extra tables.)
Upvotes: 0