您的位置:首页 > 数据库 > Oracle

52.Oracle数据库SQL开发之 子查询——编写嵌套子查询

2015-11-12 22:28 399 查看
52.Oracle数据库SQL开发之 子查询——编写嵌套子查询
欢迎转载,转载请标明出处:http://blog.csdn.net/notbaron/article/details/49805727

子查询内部可以嵌套其他子查询,嵌套层次最多为255.编程时候应该尽量少使用嵌套子查询的技术。因为使用表连接时,查询的性能可能会更高。

store@PDB1>select product_type_id,avg(price) from products group by product_type_id

    having avg(price) < (selectmax(avg(price)) from products where product_type_id in (select product_id frompurchases where quantity > 1)

    group by product_type_id) order byproduct_type_id;

 

PRODUCT_TYPE_ID AVG(PRICE)

--------------- ----------

               1    24.975

               3     13.24

               4     13.99

                        13.49
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: