SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Member
    Join Date
    Nov 2010
    Posts
    9
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    determine where error

    I need to know determine error


    SELECT DISTINCT Grade , ID FROM studentgrade ORDER BY Grade DESC
    WHERE count(Grade)=
    (SELECT count(Grade) FROM studentgrade WHERE ID=109)

  2. #2
    SQL Consultant gold trophysilver trophybronze trophy
    r937's Avatar
    Join Date
    Jul 2002
    Location
    Toronto, Canada
    Posts
    39,215
    Mentioned
    58 Post(s)
    Tagged
    3 Thread(s)
    you can't use an aggregate function like COUNT() in the WHERE clause

    you can't use an aggregate function without a GROUP BY clause unless you're counting all rows

    what you want to achieve (a rank for a specific row) will require sql that looks like this -- http://www.sitepoint.com/forums/show...63&postcount=2

    you might also want to send a message to flower.pink19 as it appears you are both working on the same homework assignment

    see http://www.sitepoint.com/forums/showthread.php?t=725435

    how interesting that both of you seem to have "flower" in your user names...

    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL
    "giving out my real stuffs"

  3. #3
    SitePoint Wizard guelphdad's Avatar
    Join Date
    Oct 2003
    Location
    St. Catharines, ON Canada
    Posts
    1,707
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You also can't put a WHERE clause after an ORDER BY clause like you have done.


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
  •