Results 1 to 2 of 2
  1. #1
    Join Date
    Aug 2004
    Posts
    77

    Unanswered: Please help.......Sql problem

    I am new in sql ......and now I have 2 tables. The first table name Table1 have 3 feilds
    id idName Name
    1 223 John
    2 32 Tim
    3 443 Carty
    4 111 Timmy
    5 27 Jam
    6 790 Max

    The second tables name Table2 have 3 fields
    idName info Co
    32 animal 4
    32 product 3
    32 city 2
    790 hat 3
    223 color 2
    223 rat 1
    111 home 1

    I want the result to display the highest number of from Co field ....This is an example of the result that I am trying to do. Anyone have any comment ...........

    idName Name info Co
    32 Tim animal 4
    790 Max hat 3
    223 John color 2
    111 Timmy home 1
    Last edited by gop373; 10-16-05 at 05:42.

  2. #2
    Join Date
    May 2002
    Posts
    299
    this should do:

    Code:
    select *
    from tb1 join (select * from tb2 x
    where x.co=(select max(co) from tb2 y
    where y.idname=x.idname)) t2 on tb1.idname=t2.idname
    --
    -oj
    http://www.rac4sql.net

Posting Permissions

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