Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to Write SQL Statement???

Status
Not open for further replies.

kolla123

Programmer
Nov 20, 2002
5
US
Hi,

I have a table like this.


ClientID Code Amount

10 UTIL $20
10 RENT $40
20 UTIL $60
10 EXPENSE $40
.....
.....

I have to write an SQL statement to get all clientids on Rows and Codes on columns

For Examp

UTIL RENT EXPENSE

ClientID

10 20 40 0
20 60 0 0

Remember that theare many codes like UTIL,RENT,EXPENSE. If you have any other solution, Please let me know.


Thanks,
Kolla
 
What you want is a crosstab query. There are many examples in the SQL Server forum. I suggest that you do keyword search for crosstab or "cross tab" in this forum. thread183-400202 is one of the threads you should find. Terry L. Broadbent - DBA
Computing Links:
faq183-874 contains "Suggestions for Getting Quick and Appropriate Answers" to your questions.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top