下面的示例查询将返回ORA-01427:单行子查询返回多行。
select product.id from product
where product.price >= (select deals.price from deals where deals.dDate >= sysdate-10)SQL中是否有什么东西可以将单个数字(本例中的产品价格)与一系列数字(本例中的交易价格)进行比较?
发布于 2018-04-24 15:00:29
您可以使用any或all,这取决于您想要的逻辑:
select product.id
from product
where product.price >= all (select deals.price from deals where deals.dDate >= sysdate-10);或者min()或max(),这取决于您想要的逻辑:
select product.id
from product
where product.price >= (select max(deals.price) from deals where deals.dDate >= sysdate-10);我更喜欢后者。
https://stackoverflow.com/questions/50004863
复制相似问题