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
 SQL Server 2008 Forums
 Other SQL Server 2008 Topics
 SQL Query needed. Please Help.

Author  Topic 

tlcpa23
Starting Member

2 Posts

Posted - 2011-06-14 : 12:37:39
Hi all. I have a problem and need a query to solve this. I have a table named GLTRAN and it has 3 columns: Acct, Batnbr, Amount. There are 3 records for Acct "120210", 4 records for Acct "120220" and 2 records for account "120230". Is there a way for the query to show the result with the sum of Amount for those 3 Acct as columns? So i want my result to show those specific accounts as my columns. Any help is greatly appreciated. Thanks everyone.

webfred
Master Smack Fu Yak Hacker

8781 Posts

Posted - 2011-06-14 : 12:41:30
select
Acct,
SUM(Amount) as Amount
from GLTRAN
group by Acct


No, you're never too old to Yak'n'Roll if you're too young to die.
Go to Top of Page

tlcpa23
Starting Member

2 Posts

Posted - 2011-06-14 : 12:45:09
Is there a way I can have those 3 accounts as columns and not rows?
Go to Top of Page
   

- Advertisement -