Skip to main content
Announcements
Introducing Qlik Answers: A plug-and-play, Generative AI powered RAG solution. READ ALL ABOUT IT!
cancel
Showing results for 
Search instead for 
Did you mean: 
ngosz4074
Contributor III
Contributor III

concatenate load SQL Select temp tables question

Hello,

I have a series of SQL statements that I need to put into one result set.

Here's a part of the SQL:

SELECT NAME,

ID,

STATUS_C,

APPT_DATE INTO #DEMO

FROM CUSTOMER

LEFT OUTER JOIN CUST_NAME ON CUST_NAME.APPT_ID = CUSTOMER.APPT_ID

WHERE SERVICE = '12345'

AND  NAME LIKE  ('%xxxx%')

AND STATUS_C IN (11,21);

SELECT #DEMO.ID,

               NAME,

               #DEMO.APPT_TIME,

               EFFECTIVE_DATE, 

               DATEDIFF(D,#DEMO.APPT_DATE, EFFECTIVE_DATE) as days into #visits

FROM #DEMO

LEFT OUTER JOIN CUSTOMER1 ON CUSTOMER1.CUST_ID = #DEMO.ID

LEFT OUTER JOIN PROCESS ON PROCESS_ID = #DEMO.PROCESS_ID

WHERE DEPT_ID IN ('51','55','61','65','71','75','81','85'

ANSD EFFECTIVE_DATE > #DEMO.APPT_DATE and

DATEDIFF(D,#DEMO.APPT_DATE, EFFECTIVE_DATE) < 31

ORDER BY NAME ASC;

it continues - but here are the first two statements.

My question is how do I take the #temp tables - do I wrap the SQL into aliased queries and concatenate them into the one script or is there another approach I'm not thinking of? 

Thanks in advance

1 Solution

Accepted Solutions
ngosz4074
Contributor III
Contributor III
Author

I have this resolved.  I placed this query into a stored procedure and have been getting this to display in my app.

View solution in original post

1 Reply
ngosz4074
Contributor III
Contributor III
Author

I have this resolved.  I placed this query into a stored procedure and have been getting this to display in my app.