Rhys answer is correct if that is what you mean, but you might want title
(s), where retail=MIN(retail)
, and this wording tells you how to get this answer:
SELECT title, retail FROM books WHERE category = 'COMPUTER' AND retail = (SELECT MIN(retail) FROM books WHERE category = 'COMPUTER')
To reduce duplication, you can use the WITH
clause (if you are using the latest version of SQL):
;WITH ComputerBooks AS ( SELECT title, retail FROM books WHERE category = 'COMPUTER') SELECT title, retail FROM ComputerBooks WHERE retail = (SELECT MIN(retail) FROM ComputerBooks)
The sample I used to validate the syntax.
source share