SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
Register Now and get your question answered!
Save Password
Forgot your Password?

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

Starting Member

21 Posts

Posted - 02/08/2013 :  05:06:24  Show Profile  Reply with Quote
I have a table that contains info:

id, date, amount, amountType

amountType has 3 valid values (1, 2, 3)

I would like to create a statement that returns

id, date, amount (where amount type = 1), amount (where amount type = 2) amount (where amount type = 3)

In reality, the table and data are more complex, but I can't get the simpler scenario to work. This isn't really that difficult, is it?

Thanks for any input...

Very Important crosS Applying yaK Herder

52326 Posts

Posted - 02/08/2013 :  05:19:19  Show Profile  Reply with Quote

FROM table t
PIVOT (SUM(amount) FOR amountType IN ([1],[2],[3]))p

SQL Server MVP

Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.05 seconds. Powered By: Snitz Forums 2000