Results 1 to 4 of 4
  1. #1
    Join Date
    Jan 2009
    Posts
    47

    Unanswered: How to implement Group By, Having and Order By in T-SQL

    Hello,
    I have to list duplicate records order by ID.
    It does not work. We can't use Group By, Having and Order by in a single script?

    select min(ID), FName,LName,Email,Count(*) FROM tblInfo
    GROUP by FName,Lname,Email
    Having Count(*)>1 Order By (ID)

  2. #2
    Join Date
    Feb 2004
    Location
    One Flump in One Place
    Posts
    14,912
    Code:
    .... Order By MIN(ID)
    Testimonial:
    pootle flump
    ur codings are working excelent.

  3. #3
    Join Date
    Apr 2002
    Location
    Toronto, Canada
    Posts
    20,002
    Code:
    SELECT MIN(ID) AS min_ID
         , FName
         , LName
         , Email
         , COUNT(*) 
      FROM tblInfo
    GROUP 
        BY FName
         , Lname
         , Email 
    HAVING COUNT(*) > 1 
    ORDER 
        BY min_ID
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL

  4. #4
    Join Date
    Jan 2009
    Posts
    47
    thanks,
    great job

Posting Permissions

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