DBAsupport.com Forums - Powered by vBulletin
Results 1 to 2 of 2

Thread: merging queries

  1. #1
    Join Date
    May 2005
    Location
    Boracay
    Posts
    681

    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';

  2. #2
    Join Date
    Mar 2004
    Location
    India
    Posts
    72
    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
  •  


Click Here to Expand Forum to Full Width