Results 1 to 4 of 4

Thread: need query

  1. #1
    Join Date
    Aug 2009
    Posts
    37

    Unanswered: need query

    i have table like this

    eid date
    1 1/1/2009
    1 2/2/2009
    2 4/5/2009
    2 5/5/2009

    i want distinct eid records with order by date.
    I wrote like this , but it is giving dummy eid , i want distinct with order by date.
    select distinct id,date from table name order by date

    thanks in advance

  2. #2
    Join Date
    Nov 2004
    Posts
    1,427
    Provided Answers: 4
    Can you show us, with the above example data, what you want as result?
    With kind regards . . . . . SQL Server 2000/2005/2012
    Wim

    Grabel's Law: 2 is not equal to 3 -- not even for very large values of 2.
    Pat Phelan's Law: 2 very definitely CAN equal 3 -- in at least two programming languages

  3. #3
    Join Date
    Oct 2002
    Location
    Leicester - UK
    Posts
    820
    Select EID, Max[Date] as MaxDate
    From Table
    Group by EID
    Order By MaxDate

    if you want to remove duplicate ID's then you need to tell it how to handle that dates that are different

    select distict will only remove ones where the dates and eid are the same
    Definition of a Beginner, Someone who doesn't know the rules.

    Definition of an Expert, Someone who knows when to ignore the rules.

  4. #4
    Join Date
    Jan 2007
    Location
    UK
    Posts
    11,434
    Provided Answers: 10
    Nice signature m.timoney
    George
    Home | Blog

Posting Permissions

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