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 )
私はSQLに非常に慣れていないので、私の質問は非常に単純ですが、1つのポイントを整理したいと思います. このクエリをこのようなものに単純化できないというのは正しいですか?
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)
それができない場合、2 つの同じサブクエリを実行するのは悪いことですか?