#1
  1. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2003
    Posts
    1
    Rep Power
    0

    Angry Select distinct but how to display all info


    You will have to forgive me I am new to this, but I want to be able to do a select distinct based on ID number, but display all information from the table just not the duplicate entries. This is what I have but obiviously doesn't work.

    select * from emp
    where id = (select distinct id from emp)
    order by last_name

    Cann someone help the new guy out?

    THanks in advance
  2. #2
  3. Modding: Oracle MsSQL Firebird
    Devshed Supreme Being (6500+ posts)

    Join Date
    Jun 2001
    Location
    Outside US
    Posts
    8,527
    Rep Power
    539
    Posting the table structure could help ...
    One thing: if "select distinct id from emp" returns more than one value you should use
    "select * from emp
    where id IN (select distinct id from emp)
    order by last_name"
  4. #3
  5. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2003
    Posts
    7
    Rep Power
    0
    SELECT DISTINCT id, field1, field2, field3, field4
    FROM table
    GROUP BY id
    ORDER BY last_name

IMN logo majestic logo threadwatch logo seochat tools logo