We help IT Professionals succeed at work.
Get Started

Adding another field/query to script

211 Views
Last Modified: 2012-05-12
I need to add another filter to show:

"INSR_Insurance"."Insurance_Sequence"=2  

so that this would pull up another name in this Select statement:

VIEW_Insurance"."Organization_Name",    so it would be called view_insurance. organization_name 2

This would show a primary insurance from insurance_sequence = 1, then selecting view_insurance.organization_name2 as the insurance name secondary insurance

thanks



SELECT "APP_Appointment"."Appointment_AppStartTime", "VIEW_Patient"."Person_DateOfBirth", "VIEW_Patient"."Person_Name", "APP_Appointment"."Appointment_Notes", "VIEW_Address"."Address_Line1", "VIEW_Address"."Address_Line2", "VIEW_Address"."Address_City", "VIEW_Address"."State_Abbreviation", "VIEW_Address"."Address_ZipCode", "APP_Appointment"."Appointment_Phone", "LKUP_VisitType"."VisitType_Description", "APP_AppointmentType"."AppointmentType_Code", "APP_Appointment"."Appointment_ID", "APP_Appointment"."Appointment_Status", "INSR_Insurance"."Insurance_Sequence", "VIEW_Patient"."Person_Sex", "VIEW_Address"."AddressType_ID", "LKUP_PatientKind"."PatientKind_Code", "VIEW_Address"."Entity_ID", "VIEW_Patient"."Patient_FileID", "APP_Appointment"."Appointment_Description", "VIEW_Insurance"."Organization_Name", "VIEW_Insurance"."Insurance_Sequence"

FROM   ((((((APP_Appointment "APP_Appointment" INNER JOIN VIEW_Patient "VIEW_Patient" ON "APP_Appointment"."Patient_ID"="VIEW_Patient"."Patient_ID") INNER JOIN APP_AppointmentType "APP_AppointmentType" ON "APP_Appointment"."AppointmentType_ID"="APP_AppointmentType"."AppointmentType_ID") INNER JOIN LKUP_VisitType "LKUP_VisitType" ON "APP_Appointment"."VisitType_ID"="LKUP_VisitType"."VisitType_ID") LEFT OUTER JOIN INSR_Insurance "INSR_Insurance" ON "VIEW_Patient"."Entity_ID"="INSR_Insurance"."Entity_ID") LEFT OUTER JOIN VIEW_Address "VIEW_Address" ON "VIEW_Patient"."Entity_ID"="VIEW_Address"."Entity_ID") INNER JOIN LKUP_PatientKind "LKUP_PatientKind" ON "VIEW_Patient"."PatientKind_ID"="LKUP_PatientKind"."PatientKind_ID") LEFT OUTER JOIN VIEW_Insurance "VIEW_Insurance" ON "INSR_Insurance"."Insurance_ID"="VIEW_Insurance"."Insurance_ID"

WHERE  ("VIEW_Address"."Entity_ID" IS  NULL  OR "VIEW_Address"."AddressType_ID"='0000000001' AND ("VIEW_Insurance"."Insurance_Sequence" IS  NULL  OR "VIEW_Insurance"."Insurance_Sequence"=1)) AND ("INSR_Insurance"."Insurance_Sequence" IS  NULL  OR "INSR_Insurance"."Insurance_Sequence"=1) AND "APP_Appointment"."Appointment_Status"<>5 AND ("APP_Appointment"."Appointment_AppStartTime">={ts '2011-11-07 00:00:00'} AND "APP_Appointment"."Appointment_AppStartTime"<{ts '2011-11-08 00:00:00'})

Comment
Watch Question
CERTIFIED EXPERT
Commented:
This problem has been solved!
Unlock 1 Answer and 4 Comments.
See Answer
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE