December 7, 2009 at 2:25 am
Hi All,
I have two tables in SQL Server
1.[Customer]
ID Name
1001 James
2.[Payments]
ID Amount CustID
1 1000 1001
2 1100 1001
3 1000 1001
4 ........
.....(can b n times)
now i require the result in this format
CUSTID Name AMT1 AMT2 AMT3
1001 James 1000 1100 1000 n so n...
I want to write a single query to access values.
Is there any way to do so ???
Please suggest..
Shatrughna
December 7, 2009 at 2:42 am
This looks like you should use Cross Tab or Pivot to get the results formatted the way you want.
There are articles aplenty with this site that can explain it better than I, but of particular interest you may want to look at:
http://www.sqlservercentral.com/Forums/Topic754045-338-1.aspx
and the excellent article it mentions within for further explanation:
http://www.sqlservercentral.com/articles/Crosstab/65048/
BrainDonor
Viewing 2 posts - 1 through 1 (of 1 total)
You must be logged in to reply to this topic. Login to reply