SELECT MIN(retail)
FROM books
WHERE category = 'COMPUTER'
works fine, but when I include title in select like:
SELECT MIN(retail), title
FROM books
WHERE category = 'COMPUTER'
it doesn’t. Why? How to make it work?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Rhys’s answer is correct, if that is what you mean, but you might have wanted the
title(s) whereretail=MIN(retail), and that wording suggests how to get that answer:To reduce duplication you can use a
WITHclause (if you’re using a recent version of SQL):Sample I used to confirm syntax.