query formating without using procs

  • Hi,

    Can one help me in formatting the query.

    I have two tables with me.

    Table-1

    select * from iw_patstrat_genpact_workdb.business_days;

    bus_hol

    2007-04-21

    2007-12-21

    2007-11-01

    2007-11-08

    2007-04-22

    2007-11-09

    2007-12-31

    2007-12-25

    2007-09-02

    2007-01-01

    2007-08-15

    2007-01-26

    2007-12-24

    Table-2

    Select

    cast(cast(N516AA_REC_DATE_CCYYMMDD As date format 'yyyymmdd') As date format 'yyyy-mm-dd') start_date, CURRENT_DATE end_date

    From eods_pcc_proddb_v.faceit;

    start_date end_date

    2007-04-17 2007-05-23

    2007-04-16 2007-05-23

    2007-05-02 2007-05-23

    2007-05-07 2007-05-23

    2007-04-14 2007-05-23

    2007-05-06 2007-05-23

    2007-05-04 2007-05-23

    2007-04-16 2007-05-23

    2007-04-17 2007-05-23

    2007-05-07 2007-05-23

    2007-05-07 2007-05-23

    2007-04-16 2007-05-23

    2007-05-07 2007-05-23

    2007-05-04 2007-05-23

    2007-05-03 2007-05-23

    2007-05-04 2007-05-23

    2007-05-04 2007-05-23

    2007-05-07 2007-05-23

    2007-04-16 2007-05-23

    2007-04-17 2007-05-23

     

    Now I want to compare the whole bus_hol column between every start date and enddate.and has to take the count of no of bus_hol existing between these start date and end date.

    Its very urgent.

    Note:- I don’t want to use any procedures or functions.Bec im working in Teradata.i need queries.

    Output:-

    start_date end_date count(bus_hol)

    2007-04-17 2007-05-23 2

    2007-04-16 2007-05-23 2

    2007-05-02 2007-05-23 0

    2007-05-07 2007-05-23 ...

    2007-04-14 2007-05-23

    2007-05-06 2007-05-23

    2007-05-04 2007-05-23

    2007-04-16 2007-05-23

    2007-04-17 2007-05-23

    2007-05-07 2007-05-23

    2007-05-07 2007-05-23

    2007-04-16 2007-05-23

    2007-05-07 2007-05-23

    2007-05-04 2007-05-23

    2007-05-03 2007-05-23

    2007-05-04 2007-05-23

    2007-05-04 2007-05-23

    2007-05-07 2007-05-23

    2007-04-16 2007-05-23

    2007-04-17 2007-05-23

    Thanks,

    Krishna

  • Nice homework question, can you ask your teacher to e-mail me, I'd like to make him a few suggestions!

Viewing 2 posts - 1 through 1 (of 1 total)

You must be logged in to reply to this topic. Login to reply