Advertisement

01.19.2006 at 10:55AM PST, ID: 21702910
[x]
Attachment Details
[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

7.6

SQL Query

Asked by running32 in MS SQL Server

Tags:

Current in the database there are a number of different queries to make up one query.  Can someone please tell me how I can join all the select statements to get just one procedure instead of the 14 I currently have.

Thanks

TABLE qselSumHV UNION ALL TABLE qselSumPA UNION ALL TABLE qselSumConnections UNION ALL TABLE qselSumDT UNION ALL TABLE qselSumSP UNION ALL TABLE qselSumMA UNION ALL TABLE qselSumPY UNION ALL TABLE qselSumHVSB UNION ALL TABLE qselSumWW UNION ALL TABLE qselSumExam UNION ALL TABLE qselSumDentrix UNION ALL TABLE qselSumVO UNION ALL TABLE qselSumConnectionsVO;


SELECT DISTINCTROW tblHVIntake.lngVisitId, tblHVIntake.dtmContact, "Health Van" AS [With], "qselSumHV" AS [Table], tblHVIntake.lngPatientId
FROM tblHVIntake;

SELECT DISTINCTROW tblPAVisit.lngVisitID, tblPAVisit.dtmContact, "Prescription Assistance" AS [With], "qselSumPA" AS [Table], tblPAVisit.lngPatientID
FROM tblPAVisit;

SELECT DISTINCTROW SQL_tblMHCIntake.lngIntakeId AS lngVisitId, SQL_tblMHCIntake.dtmIntake, "Connections" AS [With], "qselSumConnections" AS [Table], SQL_tblMHCIntake.lngPatientId
FROM SQL_tblMHCIntake;


SELECT DISTINCTROW tblDTIntake.lngVisitId, tblDTIntake.dtmContact, "Dental Program - Old" AS [With], "qselSumDT" AS [Table], tblDTIntake.lngPatientId
FROM tblDTIntake;

SELECT DISTINCTROW tblSPIntake.lngVisitId, tblSPIntake.dtmContact, "Specialty Clinic" AS [With], "qselSumSP" AS [Table], tblSPIntake.lngPatientId
FROM tblSPIntake;

SELECT DISTINCTROW tblMAIntake.lngVisitId, tblMAIntake.dtmContact, "Mammogram" AS [With], "qselSumMA" AS [Table], tblMAIntake.lngPatientId
FROM tblMAIntake;

SELECT DISTINCTROW tblPYIntake.lngVisitId, tblPYIntake.dtmAppointment, IIf([bytType]=0,"Psych Intake","Psych Monitor") & Switch([bytAppt]=4," - Excused",[bytAppt]=9," - No Show") AS [With], "qselSumPY" AS [Table], tblPYIntake.lngPatientId
FROM tblPYIntake;

SELECT DISTINCTROW tblSBHeader.lngSuperId AS lngVisitId, tblSBHeader.dtmDate, "Health Van Superbill" AS [With], "qselSumHVSB" AS [Table], tblSBHeader.lngPatientId
FROM tblSBHeader
WHERE (((tblSBHeader.lngClinicId)>9));

SELECT DISTINCTROW tblSBHeader.lngSuperId AS lngVisitId, tblSBHeader.dtmDate, "Well Womens" AS [With], "qselSumWW" AS [Table], tblSBHeader.lngPatientId
FROM tblSBHeader
WHERE (((tblSBHeader.lngClinicId)=1));

SELECT DISTINCTROW tblHBHeader.lngSuperId AS lngVisitId, tblHBHeader.dtmDate AS dtmContact, Switch([bytType]=0,"Health Consult",[bytType]=1,"Short Intake",[bytType]=2,"Immunization",[bytType]=3,"Phone Intake",[bytType]=4,"Class Intake") AS [With], "qselSumExam" AS [Table], tblHBHeader.lngPatientId
FROM tblHBHeader;


SELECT DISTINCTROW DDB_APPT_BASE.APPTID AS lngVisitId, IIf([APPTDATE]>#1/1/1900#,[APPTDATE],[BROKENDATE]) AS APPT, "Dental Program - Dentrix" & IIf([APPTDATE]<#1/1/1900#,"  *Broken Visit*") AS [With], "None" AS [Table], qjcmChartNumDentrix.MinOflngPatientId AS lngPatientId
FROM (DDB_PAT_BASE INNER JOIN DDB_APPT_BASE ON DDB_PAT_BASE.PATID = DDB_APPT_BASE.PATID) INNER JOIN qjcmChartNumDentrix ON DDB_PAT_BASE.CHART = qjcmChartNumDentrix.strPatientId
WHERE (((DDB_APPT_BASE.STATUS)=150)) OR (((DDB_APPT_BASE.APPTDATE)<#1/1/1900#));

SELECT DISTINCTROW tblVOVoucher.lngVoucherId AS lngVisitId, tblVOVoucher.dtmDate, "Voucher from " & nz([strProg]," *Not specified*") AS [With], "none" AS [Table], tblVOVoucher.lngPatientId
FROM tblVOVoucher
WHERE (((tblVOVoucher.strProg)<>"PB" And (tblVOVoucher.strProg)<>"TR"));


SELECT DISTINCTROW SQL_tblMHC_Voucher.lngVoucherId AS lngVisitId, SQL_tblMHC_Voucher.dtmCreate, "Connections Voucher" AS [With], "qselSumConnectionsVO" AS [Table], SQL_tblMHC_Voucher.lngPatientId
FROM SQL_tblMHC_Voucher;
Start Free Trial
[+][-]01.19.2006 at 11:06AM PST, ID: 15741631

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]01.19.2006 at 11:31AM PST, ID: 15741868

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]01.19.2006 at 03:06PM PST, ID: 15744116

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zone: MS SQL Server
Tags: distinctrow
Sign Up Now!
Solution Provided By: jsotech
Participating Experts: 2
Solution Grade: A
 
 
[+][-]01.20.2006 at 07:05AM PST, ID: 15749466

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]01.20.2006 at 05:45PM PST, ID: 15754298

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]01.21.2006 at 03:46AM PST, ID: 15755594

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]01.21.2006 at 07:39AM PST, ID: 15756291

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
 
Loading Advertisement...
20080716-EE-VQP-32