Results 1 to 2 of 2
  1. #1
    Join Date
    Jan 2003
    Location
    Atlanta
    Posts
    134

    Unanswered: Get MIN ROW from two tables

    I have two tables 'table1' and 'table2' which have a common column column as master child relationship.

    Table1 Table2
    cust_id cust_id
    cust_name idx
    info

    Please suggest query that joins these tables but returns only min(idx) from the 'table2' for each cust_id (one row each).

    Thanks
    Vinnie

  2. #2
    Join Date
    Oct 2001
    Location
    England
    Posts
    426
    select t1.cust_id, idx = min(t2.idx)
    from Table1 t1
    join Table2 t2
    on t1.cust_id = t2.cust_id
    group by t1.cust_id

    If some don't have children then just change join to left outer join

Posting Permissions

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