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
 query help

Author  Topic 

sunsanvin
Master Smack Fu Yak Hacker

1274 Posts

Posted - 2007-04-16 : 08:01:19
Dear Experts,
I've one result set, as shown below.I need only two rows actually.for all Bank CA-25, the UOM should be added and should display in one row.
same as for Bank CA-50 code also. please guide me.

Code Name UOM

Bank CA-25 No of Leaves 10.000
Bank CA-25 No of Leaves 100.000
Bank CA-25 No of Leaves 100.000
Bank CA-25 No of Leaves 5000.000
Bank CA-50 No of Leaves 1110.000
Bank CA-50 No of Leaves 9000.000
Bank CA-50 No of Leaves 8000.000


Thank you very much


Vinod

harsh_athalye
Master Smack Fu Yak Hacker

5581 Posts

Posted - 2007-04-16 : 08:03:18
Hint: Use GROUP BY with SUM().

Harsh Athalye
India.
"The IMPOSSIBLE is often UNTRIED"
Go to Top of Page

sunsanvin
Master Smack Fu Yak Hacker

1274 Posts

Posted - 2007-04-16 : 08:08:25
table name is table_leaves. can you please tell me the query

Vinod
Go to Top of Page

harsh_athalye
Master Smack Fu Yak Hacker

5581 Posts

Posted - 2007-04-16 : 08:16:32
Even after 100 posts, you don't know how to use GROUP BY? Try to understand the solutions posted here.

SELECT CODE, NAME, SUM(UOM) AS UOM
FROM table_leaves
GROUP BY CODE, NAME


Harsh Athalye
India.
"The IMPOSSIBLE is often UNTRIED"
Go to Top of Page

sunsanvin
Master Smack Fu Yak Hacker

1274 Posts

Posted - 2007-04-16 : 08:22:13
Actually in work hurry I was unable to think.

actually the query is so big with joins.

thank you harsha

Vinod
Go to Top of Page
   

- Advertisement -