|
|
Archives of the TeradataForum
Message Posted: Wed, 02 Sep 2009 @ 18:58:46 GMT
Subj: | | Re: Subqueries Workaround |
|
From: | | Hitesh Rana |
Hi,
Thanks for the reply. Another question for you. How do I pass the patient id to the derived tables? The query below does not work because
p.patient_id cannot be seen in those derived tables.
Select
P.patient_name
, P.Patient_age
, P.Patient_weight
, A.CountWarfarin
, B.CountHeprin
FROM patient P
, (Select Count(*) AS CountWarfarin from drug_taken WHERE drug_name='Warfarin'
patient_id=p.patient_id) A
, (Select Count(*) AS CountHeprin from drug_taken WHERE drug_name='Heprin' patient_id=
p.patient_id) B
Thank you,
-Tesh
| |