SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    Non-Member
    Join Date
    Feb 2005
    Posts
    737
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Query with unique answers?

    Hi All,

    I have a query for the follwing database where I want all answers that have a value of 'No' and the question number is 1.



    Code:
    SELECT COUNT(the_answer)
    FROM survey
    WHERE the_answer = 'No'
    AND question_number = '1';
    However, could the query be adapted to find all the unique answers in the database? IE say there were values also for 'Yes' and 'maybe' in one query for question 1, rather than outputting several different queries?

    Thanks

  2. #2
    SQL Consultant gold trophysilver trophybronze trophy
    r937's Avatar
    Join Date
    Jul 2002
    Location
    Toronto, Canada
    Posts
    39,336
    Mentioned
    63 Post(s)
    Tagged
    3 Thread(s)
    Code:
    SELECT the_answer
         , COUNT(*)
      FROM survey
     WHERE question_number = '1'
    GROUP
        BY the_answer
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL
    "giving out my real stuffs"


Bookmarks

Posting Permissions

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