hexOffender
Programmer
Here is the query I am working with:
Select distinct ADV.VisitID,ADV.AccountNumber,(select distinct InsuranceName from AdmInsuranceOrder where InsuranceOrderID='1'and VisitID=ADV.VisitID) as PrimaryInsurance,
(select InsuranceName as SecondaryInsurance from AdmInsuranceOrder where InsuranceOrderID='2'and VisitID=ADV.VisitID ) as SecondaryInsurance
from AdmInsuranceOrder
Inner Join AdmVisits as ADV on ADV.VisitID=AdmInsuranceOrder.VisitID
I need to pull the ADV.VisitID into the subquery for VisitID. Do I have to use a cursor to do this? I really dont want to because the output looks ugly.
--
Select distinct ADV.VisitID,ADV.AccountNumber,(select distinct InsuranceName from AdmInsuranceOrder where InsuranceOrderID='1'and VisitID=ADV.VisitID) as PrimaryInsurance,
(select InsuranceName as SecondaryInsurance from AdmInsuranceOrder where InsuranceOrderID='2'and VisitID=ADV.VisitID ) as SecondaryInsurance
from AdmInsuranceOrder
Inner Join AdmVisits as ADV on ADV.VisitID=AdmInsuranceOrder.VisitID
I need to pull the ADV.VisitID into the subquery for VisitID. Do I have to use a cursor to do this? I really dont want to because the output looks ugly.
--