Results 1 to 4 of 4
  1. #1
    Join Date
    Dec 2005
    Posts
    266

    Unanswered: SELECT COUNT of DISTINCT

    hello

    i want to do only one query for :

    SELECT DISTINCT Name FROM Users
    SELECT COUNT(Name) AS Names FROM Users WHERE (Name LIKE 'xxx')


    something like :

    SELECT Name, COUNT(Name) AS Names FROM Users WHERE Name IN (SELECT DISTINCT Name FROM Users)

    i must get :

    Joe 23
    julie 17
    .....


    thank you

  2. #2
    Join Date
    Apr 2002
    Location
    Toronto, Canada
    Posts
    20,002
    SELECT Name, COUNT(*) AS Names FROM Users GROUP BY Name
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL

  3. #3
    Join Date
    Dec 2005
    Posts
    266
    it works

    thanks once more !

  4. #4
    Join Date
    Nov 2002
    Location
    Jersey
    Posts
    10,322
    Quote Originally Posted by anselme
    it works

    thanks once more !

    Of course it works...Rudy only handles the most difficult questions here at dbforums....
    Brett
    8-)

    It's a Great Day for America everybody!

    dbforums Yak CorralRadio 'Rita
    dbForums Member List
    I'm Good Once as I ever was

    The physical order of data in a database has no meaning.

Posting Permissions

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