Converting rows into columns | SQL Server Performance Forums

SQL Server Performance Forum – Threads Archive

Converting rows into columns

HI, I need to convert the rows into columns, i tried to do it by crosstab queries but the problem is the result i need on the basis of some condition for example Table A Status Userid Points Datecreated
Awarded A 1000 Jan 2007
Awarded B 1000 Jan 2007
Awarded B 2000 Feb 2007
Pending A 1000 Feb 2007
Pending B 500 Jan 2007
Pending C 600 Feb 2007
Expired D 800 Jan 2007
Expired A 900 Feb 2007 Table B Userid Status
A Active
B Inactive
C Active
D Active
I need the output in two format by joining 2 tables with userid and users status should be active Awarded Expired pending
Jan 2007 2000 800 500
Feb 2007 Jan 2007 Feb 2007
Awarded 2000
Expired 800
Pending 500 Regards
Satya SKJ
Microsoft SQL Server MVP
Writer, Contributing Editor & Moderator
This posting is provided AS IS with no rights for the sake of knowledge sharing. The greatest discovery of my generation is that a human being can alter his life by altering his attitudes of mind.