SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


Group by


Group by

Author
Message
Manie Verster
Manie Verster
Hall of Fame
Hall of Fame (3.8K reputation)Hall of Fame (3.8K reputation)Hall of Fame (3.8K reputation)Hall of Fame (3.8K reputation)Hall of Fame (3.8K reputation)Hall of Fame (3.8K reputation)Hall of Fame (3.8K reputation)Hall of Fame (3.8K reputation)

Group: General Forum Members
Points: 3780 Visits: 1048
Thanks to all for the positive comments and thanks Hugo for the logical explanation you gave. Helps a lot!

Tom please tell me what this means. "Na tog mi gun tuit mi ach ma thuiteas tog! Thig crìoch air an t-saoghal ach mairidh gaol is ceòl "

:-PManie Verster
Developer
Johannesburg
South Africa

I can do all things through Christ who strengthens me. - Holy Bible
I am a man of fixed and unbending principles, the first of which is to be flexible at all times. - Everett Mckinley Dirkson (Well, I am trying. - Manie Verster)
Hugo Kornelis
Hugo Kornelis
SSC-Dedicated
SSC-Dedicated (34K reputation)SSC-Dedicated (34K reputation)SSC-Dedicated (34K reputation)SSC-Dedicated (34K reputation)SSC-Dedicated (34K reputation)SSC-Dedicated (34K reputation)SSC-Dedicated (34K reputation)SSC-Dedicated (34K reputation)

Group: General Forum Members
Points: 34350 Visits: 13119
Manie Verster (9/10/2010)
Tom please tell me what this means. "Na tog mi gun tuit mi ach ma thuiteas tog! Thig crìoch air an t-saoghal ach mairidh gaol is ceòl "

Google translate recognises it as Scottish Celtic, but is not yet able to translate that to either English or Dutch.
Bing Translator thinks it's Hungarian and translates it to English as "Na train what gun tuit what ach thuiteas train today! Thig crìoch air an t-saoghal ach mairidh gaol also ceòl".
Guess which of the two competing sites I believe ;-)


Hugo Kornelis, SQL Server/Data Platform MVP (2006-2016)
Visit my SQL Server blog: http://sqlblog.com/blogs/hugo_kornelis
Tom Thomson
Tom Thomson
SSC Guru
SSC Guru (50K reputation)SSC Guru (50K reputation)SSC Guru (50K reputation)SSC Guru (50K reputation)SSC Guru (50K reputation)SSC Guru (50K reputation)SSC Guru (50K reputation)SSC Guru (50K reputation)

Group: General Forum Members
Points: 50688 Visits: 13159
Manie Verster (9/10/2010)
Tom please tell me what this means. "Na tog mi gun tuit mi ach ma thuiteas tog! Thig crìoch air an t-saoghal ach mairidh gaol is ceòl "

As Hugo said, it's Scotland's Celtic language, usually in English called Scottish Gaelic, or Gaelic for short (which of course creates confusion with Manx and Irish Gaelics) or in itself Gàidhlig na h-Alba. The first line means literally "Don't lift me unless I fall but if I fall do lift" but really "don't correct me unless I'm wrong but if I'm wrong do". The second line is a very old saying: "An end will come upon the world but love and music will survive".

Tom

Daniel Bowlin
Daniel Bowlin
SSCoach
SSCoach (17K reputation)SSCoach (17K reputation)SSCoach (17K reputation)SSCoach (17K reputation)SSCoach (17K reputation)SSCoach (17K reputation)SSCoach (17K reputation)SSCoach (17K reputation)

Group: General Forum Members
Points: 17442 Visits: 2629
I was up late last night working. I am looking at the question and thinking, "Gee, I didn't think you could group that way" and in my fatigue I chose the wrong answer instead of realizing that you can't group that way.
Paul White
Paul White
SSC Guru
SSC Guru (79K reputation)SSC Guru (79K reputation)SSC Guru (79K reputation)SSC Guru (79K reputation)SSC Guru (79K reputation)SSC Guru (79K reputation)SSC Guru (79K reputation)SSC Guru (79K reputation)

Group: General Forum Members
Points: 79742 Visits: 11400
There is a "workaround":


SELECT DV.[Year],
SOH.SalesPersonID,
AverageOrderAmt = SUM(SOH.TotalDue)
FROM Sales.SalesOrderHeader SOH
CROSS
APPLY (SELECT DATEPART(yyyy,OrderDate)) DV ([Year])
GROUP BY
DV.[Year],
SOH.SalesPersonID
ORDER BY
DV.[Year] ;



Over to you, Hugo.

Paul



Paul White
SQLPerformance.com
SQLblog.com
@SQL_Kiwi
VinceV
VinceV
Mr or Mrs. 500
Mr or Mrs. 500 (547 reputation)Mr or Mrs. 500 (547 reputation)Mr or Mrs. 500 (547 reputation)Mr or Mrs. 500 (547 reputation)Mr or Mrs. 500 (547 reputation)Mr or Mrs. 500 (547 reputation)Mr or Mrs. 500 (547 reputation)Mr or Mrs. 500 (547 reputation)

Group: General Forum Members
Points: 547 Visits: 136
Great question and even better follow up discussions. Thanks!
timothy bates
timothy bates
Old Hand
Old Hand (324 reputation)Old Hand (324 reputation)Old Hand (324 reputation)Old Hand (324 reputation)Old Hand (324 reputation)Old Hand (324 reputation)Old Hand (324 reputation)Old Hand (324 reputation)

Group: General Forum Members
Points: 324 Visits: 128
Based on Hugo's LOGICAL progression where the group by preceeds the select. The alias is not yet defined so grouping is not possible against a column that does not yet exist. The Order By occurs post Select where the alias has been defined so it is acceptable. An alternative solution is Group by datepart(yyyy,orderdate).
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum








































































































































































SQLServerCentral


Search