Results 1 to 5 of 5
  1. #1
    Join Date
    Apr 2004
    Posts
    113

    Unanswered: Need specific dates

    Hello,

    I need to pull all dates from 8/2003-7/2004 for specific events.
    Here is my query:

    insert into t_tv2
    select j.market_code,j.list_acct_no, sum(event_counter) tv
    from jug j
    where event_code in (222, 922, 1122)
    and month_no <= 7
    and year_no <= 2004
    group by j.market_code, j.list_acct_no;
    commit;

  2. #2
    Join Date
    Jun 2004
    Location
    Liverpool, NY USA
    Posts
    2,509
    How is the data stored. Your fields month_no and year_no, are they the actual montah and date. Do you acutally have a date field containing the approporate date info. information? You should never store date information as seperate fields. That is what the date or timestamp field is for. Could you sho the describe for the jug table.
    Bill
    You do not need a parachute to skydive. You only need a parachute to skydive twice.

  3. #3
    Join Date
    Apr 2004
    Posts
    113
    Jug

    (
    Market_code Char(2) Not Null,
    List_acct_no Number Not Null,
    Event_code Number Null,
    Event_counter Number Not Null,
    Month_no Number Not Null,
    Year_no Number Not Null
    )

  4. #4
    Join Date
    Jun 2004
    Location
    Liverpool, NY USA
    Posts
    2,509
    Quote Originally Posted by newbie2004
    Jug

    (
    Market_code Char(2) Not Null,
    List_acct_no Number Not Null,
    Event_code Number Null,
    Event_counter Number Not Null,
    Month_no Number Not Null,
    Year_no Number Not Null
    )
    insert into t_tv2
    select j.market_code,j.list_acct_no, sum(event_counter) tv
    from jug j
    where event_code in (222, 922, 1122)
    and to_date(to_char(month_no)||'/01/'||to_char(year_no),'mm/dd/yyyy') between
    to_date('08/01/2003','MM/DD/YYYY') and to_date('07/01/2004','MM/DD/YYYY)
    group by j.market_code, j.list_acct_no;
    commit;


    In the future always use a date field. Never store the individual date elements.
    Bill
    You do not need a parachute to skydive. You only need a parachute to skydive twice.

  5. #5
    Join Date
    Apr 2004
    Posts
    113
    Thank you beilstwh!!!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •