Results 1 to 4 of 4
  1. #1
    Join Date
    Oct 2004
    Posts
    2

    Unanswered: Help updating a table with values from another table.

    I really need some help with an update statement in Oracle.

    I have 2 tables in an Oracle DB. Table 1 has a structure of
    MDW_Year Integer null,
    MDW_Month integer null,
    MDW_Mth_Desc varchar2(3) null,
    MDW_DOW varchar2(12) null,
    MDW_Nbr_MCMR integer null,
    MDW_Nbr_DCMR integer null,
    MDW_Nbr_DOWPCT integer null

    I have populated table 1 with a record for the year = 2004, months jan through dec and dow sun through sat for each month. I need to update the field mdw_nbr_dcmr with the value of the field mdwi_nbr_mcmr field from the second table. where table1.year = table2.year and table1.month=table2.month and table1.dow=table2.dow.

    Table 2 has a a structure of
    MDWI_Year Integer null,
    MDWI_Month integer null,
    MDWI_DOW varchar2(12) null,
    MDWI_Nbr_MCMR integer null

    nothing i have done works can someone provide some help.

    thanks

  2. #2
    Join Date
    Jun 2004
    Location
    Liverpool, NY USA
    Posts
    2,509
    Why didn't you use a data column, all the information DOW,month,year and a lot more is implicint to a date.
    Bill
    You do not need a parachute to skydive. You only need a parachute to skydive twice.

  3. #3
    Join Date
    Oct 2004
    Posts
    2
    Bill,
    what I'm trying to do, and maybe not correctly, is summarize information by Year, Month, and Day of the Week ie. Monday. If i use date column i think i'll end up with summarizations by specific date.

  4. #4
    Join Date
    Jun 2004
    Location
    Liverpool, NY USA
    Posts
    2,509
    Select sum(MDW_Nbr_MCMR )
    from table1
    where to_char(MyDateField,'DAY') = 'MONDAY';

    Select sum(MDW_Nbr_MCMR )
    from table1
    where to_char(MyDateField,'YYYY MON') = '2004 JAN';

    Select sum(MDW_Nbr_MCMR )
    from table1
    where to_char(MyDateField,'MONTH') = 'JANUARY';

    Select sum(MDW_Nbr_MCMR )
    from table1
    where to_char(MyDateField,'DAY') = 'MONDAY'
    and to_char(MyDateField,'YYYY') = '2004';


    A date field gives you flexability to do anything.
    Last edited by beilstwh; 10-27-04 at 16:56.
    Bill
    You do not need a parachute to skydive. You only need a parachute to skydive twice.

Posting Permissions

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