update table from another table with agrigate functions

  • Hello all,

    I have two tables, tbl1 and tbl2.

    tbl1 has a single unique record. tbl2 has many records per unique record.

    In table 1 I have specified a start_date and end_date field.

    I can update the end_date field using this SQL line.

    UPDATE tbl_1

    SET tbl_1.date_Last = tbl2.HIST_DATE

    FROM tbl_1,tbl_2

    where tbl_1.query_sequence = tbl_2.query_sequence

    but I can't get the start_date value into the tbl1.date_start

    I have tried SET tbl_1.date_Last = min(tbl2.HIST_DATE) as minDate

    but this doesnt work

    any ideas?

    many thanks

    Dave

  • to get around this, I had to create a stored procedure and loop through table 1, then check for the first record in table2, then update table 1 with the details.. geeze,

    i thought it would have been easier then this.

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

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