select model from (
select price, model from pc where price = (select max(price) from pc)
union
select price, model from laptop where price = (select max(price) from laptop)
union
select price, model from printer where price = (select max(price) from printer)
) t1 where price = (select max(price) from (
select price, model from pc where price = (select max(price) from pc)
union
select price, model from laptop where price = (select max(price) from laptop)
union
select price, model from printer where price = (select max(price) from printer)
) t2 )
I'm very new to SQL so my question is very simple, but I would like to sort out one point. Am I right that this query can not be simplified to something like this?
select model from (
select price, model from pc where price = (select max(price) from pc)
union
select price, model from laptop where price = (select max(price) from laptop)
union
select price, model from printer where price = (select max(price) from printer)
) t1 where price = (select max(price) from t1)
And if it can not be, is it a bad thing that we run two same subqueries?