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.
| Author |
Topic |
|
sqlclarify
Yak Posting Veteran
56 Posts |
Posted - 2008-09-17 : 13:10:55
|
| I have a queryselect a , b, c,sum(q)....group by a,b,cI want to group by only a. How do I do that? If I remove b and c from the group by I get an erro.Thanks. |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2008-09-17 : 13:14:37
|
| [code]select t1.a,t1.b,t1.c,t2.sumqfrom table t1inner join (select a,sum(q) as sumq from table group by a) t2on t2.a=t1.a[/code] |
 |
|
|
sqlclarify
Yak Posting Veteran
56 Posts |
Posted - 2008-09-17 : 13:20:16
|
| How do I determine what the key of the inner table t2 is? I have 5 joined tables in place of t2.Thanks a lot for your reply!:) |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2008-09-17 : 13:21:33
|
quote: Originally posted by sqlclarify How do I determine what the key of the inner table t2 is? I have 5 joined tables in place of t2.Thanks a lot for your reply!:)
then show your current code. |
 |
|
|
sqlclarify
Yak Posting Veteran
56 Posts |
Posted - 2008-09-17 : 14:36:03
|
| if you join the grouped table t2 to the other table will it still retain the grouping? |
 |
|
|
sqlclarify
Yak Posting Veteran
56 Posts |
Posted - 2008-09-17 : 15:43:26
|
| ok, now I have another problemIn table 2 I have (select key,groupbycol,sum(c) from table groupbycol,keyI don't want it to be grouped by key. How do I solve this? |
 |
|
|
sqlclarify
Yak Posting Veteran
56 Posts |
Posted - 2008-09-17 : 16:48:20
|
| sorry I can't paste my code here because its work related but I really appreciate your advice. |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2008-09-18 : 00:05:18
|
quote: Originally posted by sqlclarify sorry I can't paste my code here because its work related but I really appreciate your advice.
without knowing your scenario how can i suggest something? give atleast a sample code illustrating your scenario. |
 |
|
|
|
|
|
|
|