|
database
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
grouping questionhey all,
i have 2 tables. i'm grouping on table1 i'd like to join this to table2 which would create 1 to 1 relationship. when add extra fields from table2 it forces me to group by these fields as well. Can someone please explain this concept to me? thanks, rodchar Could you give better specs?
http://www.aspfaq.com/5006 Show quote "rodchar" <rodc***@discussions.microsoft.com> wrote in message news:DAD412E6-9F72-42D2-8220-A8905E863944@microsoft.com... > hey all, > > i have 2 tables. i'm grouping on table1 i'd like to join this to table2 > which would create 1 to 1 relationship. when add extra fields from table2 > it > forces me to group by these fields as well. Can someone please explain > this > concept to me? > > thanks, > rodchar Can you post what you are doing to have an idea of what you are talking about?
AMB Show quote "rodchar" wrote: > hey all, > > i have 2 tables. i'm grouping on table1 i'd like to join this to table2 > which would create 1 to 1 relationship. when add extra fields from table2 it > forces me to group by these fields as well. Can someone please explain this > concept to me? > > thanks, > rodchar rodchar wrote:
> hey all, All columns must appear in a group by clause unless you are using an > > i have 2 tables. i'm grouping on table1 i'd like to join this to > table2 which would create 1 to 1 relationship. when add extra fields > from table2 it forces me to group by these fields as well. Can > someone please explain this concept to me? > > thanks, > rodchar aggregate. From BOL: "When GROUP BY is specified, either each column in any non-aggregate expression in the select list should be included in the GROUP BY list, or the GROUP BY expression must match exactly the select list expression." If you were allowed to leave a column off the Group By clause, what value would SQL Server use for the result set (assuming there were multiple matches)? You may be able to use a derived table to do what you want, but as Aaron mentioned, we need some more details. thanks David and everyone this helped.
Show quote "David Gugick" wrote: > rodchar wrote: > > hey all, > > > > i have 2 tables. i'm grouping on table1 i'd like to join this to > > table2 which would create 1 to 1 relationship. when add extra fields > > from table2 it forces me to group by these fields as well. Can > > someone please explain this concept to me? > > > > thanks, > > rodchar > > All columns must appear in a group by clause unless you are using an > aggregate. From BOL: "When GROUP BY is specified, either each column in > any non-aggregate expression in the select list should be included in > the GROUP BY list, or the GROUP BY expression must match exactly the > select list expression." > > If you were allowed to leave a column off the Group By clause, what > value would SQL Server use for the result set (assuming there were > multiple matches)? > > You may be able to use a derived table to do what you want, but as Aaron > mentioned, we need some more details. > > > -- > David Gugick > Quest Software > www.imceda.com > www.quest.com > > The GROUP BY clause is explained here:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/tsqlref/ts_sa-ses_9sfo.asp
ML |
|||||||||||||||||||||||