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 derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

CrossTab based on 2 fields

Status
Not open for further replies.

anandviru

Technical User
Joined
Nov 16, 2011
Messages
6
Location
US
This is what the data looks like :

RecordNumber Complication1 Complication2 Grade-Complication1 Grade-Complication2
XX1001 surgical ortho I III
XX1002 surgical neuro I II
XX1003 neuro ortho III I
XX1004 surgical surgical II III

Desired crosstab output :

Complication GradeI GradeII GradeIII Total
surgical 2 1 1 4
ortho 1 0 1 2
neuro 1 0 1 2

Can someone help me on how to built this crosstab ? . Please let me know if you have any question on the sample data given above.
 
You can not do this in crystal directly you will need to build a view of data or use a command

Select RecordNumber, Complication1, grade_complication1, 'Complication1' as ComplicationType
from yourtable
union all
Select RecordNumber, Complication2, grade_complication2, 'Complication2' as ComplicationType
from your table

You can now easily perform cross tab on this data set.

Ian
 
Thank you so much Ian. That really works !!!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top