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 很陌生,所以我的问题很简单,但我想理清一点。我对这个查询不能简化为这样的事情是对的吗?
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)
如果不能,我们运行两个相同的子查询是不是一件坏事?