Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Author |
Topic |
mikebird
Aged Yak Warrior
529 Posts |
Posted - 2009-09-17 : 07:19:33
|
How do I divide one column into three seperate ones with nested / sub queries? The where clause picks the three values I need to use, but I need each AttendanceType to be a column, with values of it's own - possibly grouping to summarise. Live a pivot table? To have the same columns either side, how do I do the parenthesis syntax to get this?Thanksselect distinctDG.PatientNumber,AttendanceType,PostCode,AttendanceDatefrom Demographic DGinner join vrAttendance A on A.PatientNumber = DG.PatientNumberinner join Diagnosis D on D.PatientNumber = DG.PatientNumberwhere AttendanceType in ('New Patient','Follow-up (Old)','Rebook Patient')and D.DiagnosisDate between '10-09-2009' and '17-09-2009' |
|
webfred
Master Smack Fu Yak Hacker
8781 Posts |
Posted - 2009-09-17 : 07:28:38
|
So 2 of that 3 columns are always null or whatever? No, you're never too old to Yak'n'Roll if you're too young to die. |
|
|
mikebird
Aged Yak Warrior
529 Posts |
Posted - 2009-09-17 : 07:43:44
|
Rather than having AttendanceTypePatient A NewPatient B Follow-upPatient C RebookPatient D Newrepeated.....want to have New Follow-up Rebook A 1 2 2 zipcode...B 1 0 1C 1 0 0D 1 5 3------------------------------ 4 7 6is it necessary to nullify some columns? |
|
|
mikebird
Aged Yak Warrior
529 Posts |
Posted - 2009-09-17 : 07:52:50
|
oh that did not lay out very nicely |
|
|
|
|
|