Results 1 to 7 of 7

Thread: Distinct count?

  1. #1
    Join Date
    Jun 2007
    Posts
    40

    Unanswered: Distinct count?

    Is it possible to use the DISTINCT keyword with the Count() function? So for example if we have a query

    Code:
    SELECT DISTINCT Table1.Field1 FROM Table1 WHERE Table1.Field2 = 0;
    Then can I find out how many records this query returned? I know that I can do

    Code:
    SELECT Count(*) FROM Table1 WHERE Table1.Field2 = 0;
    but this would distinguish between duplicate Field1, which the first query wouldn't.

  2. #2
    Join Date
    Apr 2002
    Location
    Toronto, Canada
    Posts
    20,002
    take your SELECT DISTINCT query and save it as a saved query

    then query the saved query like this --
    Code:
    select count(*) from savedquery
    vwalah!!
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL

  3. #3
    Join Date
    Jan 2007
    Location
    UK
    Posts
    11,434
    Provided Answers: 10
    George
    Home | Blog

  4. #4
    Join Date
    Apr 2002
    Location
    Toronto, Canada
    Posts
    20,002
    thank you , george, but as that page you linked to says, it's a "barbarous misspelling"

    however, when i use it, it is ~not~ because of my reluctance to believe that OI can represent the sound "wah"

    i have a different reason
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL

  5. #5
    Join Date
    Jan 2007
    Location
    UK
    Posts
    11,434
    Provided Answers: 10
    Quote Originally Posted by r937
    i have a different reason
    Oh no you cannot leave me hanging like that!
    George
    Home | Blog

  6. #6
    Join Date
    Feb 2004
    Location
    One Flump in One Place
    Posts
    14,912
    I always assumed nothing more (or indeed less) than comedic value.
    Testimonial:
    pootle flump
    ur codings are working excelent.

  7. #7
    Join Date
    Apr 2002
    Location
    Toronto, Canada
    Posts
    20,002
    Quote Originally Posted by georgev
    Oh no you cannot leave me hanging like that!
    oh yes i can ;o)
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL

Posting Permissions

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