-
merging queries
Hi Friends,
I have eight (8) sql queries being run againts one table that eat lots
of resources because its being run eight times. I just feel i can merge this queries into one, but im confused how.
Can you help me please.... Thanks a lot
select count(*) from departure_all partition (depart2006)
where to_char(exit_date,'MON')='MAY' AND PORT='A' AND SUBSTR(CITZ,1,2)='PH';
select count(*) from departure_all partition (depart2006)
where to_char(exit_date,'MON')='JUN' AND PORT='A' AND SUBSTR(CITZ,1,2)='PH';
select count(*) from departure_all partition (depart2006)
where to_char(exit_date,'MON')='MAY' AND PORT='A' AND SUBSTR(CITZ,1,2)<>'PH';
select count(*) from departure_all partition (depart2006)
where to_char(exit_date,'MON')='JUN' AND PORT='A' AND SUBSTR(CITZ,1,2)<>'PH';
select count(*) from departure_all partition (depart2006)
where to_char(exit_date,'MON')='MAY' AND PORT='B' AND SUBSTR(CITZ,1,2)='PH';
select count(*) from departure_all partition (depart2006)
where to_char(exit_date,'MON')='JUN' AND PORT='B' AND SUBSTR(CITZ,1,2)='PH';
select count(*) from departure_all partition (depart2006)
where to_char(exit_date,'MON')='MAY' AND PORT='B' AND SUBSTR(CITZ,1,2)<>'PH';
select count(*) from departure_all partition (depart2006)
where to_char(exit_date,'MON')='JUN' AND PORT='B' AND SUBSTR(CITZ,1,2)<>'PH';
-
Use CASE WHEN Statement..
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|