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 Issue

Author  Topic 

mkgmahi
Starting Member

24 Posts

Posted - 2011-07-24 : 08:01:53
Hi Folks,


I am facing an issue in an SQL Query where in i need to group and get summation for some of the rows by main column and the other rows by the other individual column. I have tried providing the two columns in the group by but they are getting grouped by individual column. Please help me out

EX cola colb colc cold
1 sec 234
2 sec sec1 233

GilaMonster
Master Smack Fu Yak Hacker

4507 Posts

Posted - 2011-07-24 : 08:21:10
Please post the query that you have, the table definition and what you want as results.

--
Gail Shaw
SQL Server MVP
Go to Top of Page

eralper
Yak Posting Veteran

66 Posts

Posted - 2011-07-25 : 01:53:27
Hello,

You can use SUM() aggregate function with Group By clause

Besides, you can use SUM() OVER (Partition By) clause. In this case it is not necessary to use Group By

In this sample [url]http://www.kodyaz.com/t-sql/sql-count-function-with-partition-by-clause.aspx[/url] the aggregate function Count() is used with Partition By clause. You can use Sum() and other aggregate functions with Partition clause as well

-------------
Eralper
http://www.kodyaz.com
Go to Top of Page
   

- Advertisement -