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 |
|
josh2009
Yak Posting Veteran
81 Posts |
Posted - 2009-08-25 : 14:15:34
|
| I'm writing a query to display all equipment used for different procedures and having problems joining the tables. Here is my query -select Demographics."Last_Name", Demographics."First_Name", Demographics."Patient_ID", Demographics."Date_of_Birth", Event_Cath."Account_Number", Event_Cath."Date_of_Cath", Event_Cath."Room", Event_Cath.ss_event_cath_id, Cath_Equipment."Item", Cath_Equipment."Quantity_Used", Cath_Procedures."Procedure_Name"from demographicsinner join event_cath ON Event_Cath."SS_Patient_ID" = Demographics."SS_Patient_ID" inner join cath_equipment on event_cath.ss_event_cath_id = cath_equipment.ss_event_cath_id join cath_procedures on cath_equipment.ss_event_cath_id = cath_procedures.ss_event_cath_id Result set for ONE Patient -AAAA 30cc IABP 7Fr Coronary AngiographyAAAA 100cc Visipaque 320mgI/ml Coronary AngiographyAAAA Left Heart Kit Coronary AngiographyAAAA Wire .035 Fixed J 145cm Coronary AngiographyAAAA 6Fr Sheath 10cm Coronary AngiographyAAAA Multi-pack JL4, JR4,Angl Pig 6Fr Coronary AngiographyAAAA 8Fr sheath 24cm Coronary AngiographyAAAA 8Fr 55cm Raabe sheath Coronary AngiographyAAAA 100cc Visipaque 320mgI/ml Coronary AngiographyAAAA 40cc IABP 8Fr Coronary AngiographyAAAA 30cc IABP 7Fr Left Heart CatheterizationAAAA 100cc Visipaque 320mgI/ml Left Heart CatheterizationAAAA Left Heart Kit Left Heart CatheterizationAAAA Wire .035 Fixed J 145cm Left Heart CatheterizationAAAA 6Fr Sheath 10cm Left Heart CatheterizationAAAA Multi-pack JL4, JR4,Angl Pig 6Fr Left Heart CatheterizationAAAA 8Fr sheath 24cm Left Heart CatheterizationAAAA 8Fr 55cm Raabe sheath Left Heart CatheterizationAAAA 100cc Visipaque 320mgI/ml Left Heart CatheterizationAAAA 40cc IABP 8Fr Left Heart CatheterizationAAAA 30cc IABP 7Fr Left Ventricular AngiogramAAAA 100cc Visipaque 320mgI/ml Left Ventricular AngiogramAAAA Left Heart Kit Left Ventricular AngiogramAAAA Wire .035 Fixed J 145cm Left Ventricular AngiogramAAAA 6Fr Sheath 10cm Left Ventricular AngiogramAAAA Multi-pack JL4, JR4,Angl Pig 6Fr Left Ventricular AngiogramAAAA 8Fr sheath 24cm Left Ventricular AngiogramAAAA 8Fr 55cm Raabe sheath Left Ventricular AngiogramAAAA 100cc Visipaque 320mgI/ml Left Ventricular AngiogramAAAA 40cc IABP 8Fr Left Ventricular AngiogramThis is just a partial result set. As you can see, for this patient, rows are repeated for every item depending on the number of procedures done for this patient. And I can't find any other key I can use for a more solid join. Any help will be greatly appreciated. Thanks |
|
|
webfred
Master Smack Fu Yak Hacker
8781 Posts |
Posted - 2009-08-25 : 18:23:53
|
So how would the "correct" output look like? No, you're never too old to Yak'n'Roll if you're too young to die. |
 |
|
|
|
|
|
|
|