var sidebar_align = 'right';
var content_container_margin = parseInt('290px');
var sidebar_width = parseInt('270px');
Unanswered: Selecting things greater than the max of something else
Let's pretend I have this table
I need to select the name of all of the items that have a price greater than the max price of all items of a certain type.
So, if I have 20 items in the table and 4 of them are of type 'A' and the max price for any item of type 'A' is 10, I need to select all items of the 20 with a price greater than 10.
I tried joining the table with itself, but that didn't work so well. Can anyone tell me how to do this?
this is a classic homework assignment, isn't it?
okay, can you write the query to find the largest price for type A items?
show me that, and i'll show you how to use it in a subquery
SELECT MAX(price) AS maxPrice FROM table WHERE type = 'A';
now here's how to return the names of all items that have a higher price --
WHERE price >
( SELECT MAX(price) AS maxPrice
WHERE type = 'A' )
note that the maxPrice alias isn't actually needed