|
|
Archives of the TeradataForum
Message Posted: Wed, 02 Sep 2009 @ 17:09:04 GMT
Subj: | | Re: Subqueries Workaround |
|
From: | | babak.teymouri |
Hi,
This is named "scalar subquery", there is two options: (move to TD13 :-) or rewrite the query by using cross join and derivad table :
Select distinct
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=10) A
, (Select Count(*) AS CountHeprin from drug_taken WHERE drug_name='Heprin' patient_id=10) B
WHERE P.patient_id=10
B.Teymouri
| |