Quantcast
Channel: Teradata Forums - Database
Viewing all articles
Browse latest Browse all 14773

Combine Multiple Select Statements - response (5) by dnoeth

$
0
0

Just put each SELECT in a Dervived Table and Join them on the DATE.
Additionally you might reduce the number of queries by combining those with the same JOINs, but different WHERE into a single query, e.g. the last three:
 

SELECT 
   COUNT(DISTINCT CASE WHEN CA.T_CODE IN ('Rose_A') THEN RP.MCPR_ID END)
  ,COUNT(DISTINCT CASE WHEN CA.T_CODE IN ('Rose_B') THEN RP.MCPR_ID END)
  ,COUNT(DISTINCT CASE WHEN CA.T_CODE IN ('Rose_C') THEN RP.MCPR_ID END)

Dieter


Viewing all articles
Browse latest Browse all 14773

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>