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

    Question Unanswered: SQL query. Why is it so?

    My SQL query is as follows
    Code:
    select title
    from book B
    where (select count(*)
               from book T
               where (T.price > B.price) < 5
    This query returns the 5 most expensive books. If I do >5, it is returning the 4 most expensive books. What is the concept behind this? Why is it so?

  2. #2
    Join Date
    Aug 2003
    Location
    Where the Surf Meets the Turf @Del Mar, CA
    Posts
    7,776
    Provided Answers: 1
    >This query returns the 5 most expensive books. If I do >5, it is returning the 4 most expensive books. What is the concept behind this? Why is it so?

    post reproducible proof.
    You can lead some folks to knowledge, but you can not make them think.
    The average person thinks he's above average!
    For most folks, they don't know, what they don't know.
    Good judgement comes from experience. Experience comes from bad judgement.

  3. #3
    Join Date
    Jul 2003
    Posts
    2,296
    I fail to see how this query accomplishes what you describe.
    it's not even syntactically correct.
    - The_Duck
    you can lead someone to something but they will never learn anything ...

  4. #4
    Join Date
    Apr 2002
    Location
    Toronto, Canada
    Posts
    20,002

Posting Permissions

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