Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 group by

Author  Topic 

smile
Starting Member

22 Posts

Posted - 2009-03-29 : 17:50:23
Hello!

Here's what I want to ask: when we use group by clause with more than one table..let's say two tables, which is the table that will be used firstly to group the results? From my examples I get the impression that if i have something like "group by t1,t2", then in the result the first grouping is formed with t2 and then the already obtained groups are grouped (or divided) by t1? I expected it to group in the order I've written the tables....am I right or not?

Thanks a lot in advance...you're helping me very much!

LoztInSpace
Aged Yak Warrior

940 Posts

Posted - 2009-03-30 : 00:15:38
You group by columns not by tables and it works left to right. Take a look at any SQL reference to work it out.
Go to Top of Page

smile
Starting Member

22 Posts

Posted - 2009-03-30 : 03:32:45
Yeah...it's my mistake about writing "tables" instead of "columns"...

Ok..thanks!


Go to Top of Page
   

- Advertisement -