|
|
Archives of the TeradataForum
Message Posted: Wed, 02 Sep 2009 @ 20:30:33 GMT
Subj: | | Re: Subqueries Workaround |
|
From: | | Leslie, Quincy |
To use the same/similar SQL, try adding a WHERE clause, i.e.
Select
P.patient_name
, P.Patient_age
, P.Patient_weight
, A.CountWarfarin
, B.CountHeprin
, P.patient_id
FROM patient P
, (Select Count(*) AS CountWarfarin from drug_taken WHERE drug_name='Warfarin') A
, (Select Count(*) AS CountHeprin from drug_taken WHERE drug_name='Heprin') B
WHERE
A.patient_id=p.patient_id AND
B.patient_id=p.patient_id
| |