解决查询时分组条件中不存在列的变通使用

通常在分组select时,select出来的列必须要在分组条件中存在或应用聚合函数,现在我们可以通过oracel的一些分析函数来解决这个问题,例子如下:

select t2.*
from (
select t1.*,row_number() over(partition by t1.orderid order by t1.price_net

) rn
from order_detail t1) t2
where t2.rn = 1
其中orderid为分组的列,price_net为使用聚合函数的列,对分组记录进行排序,取出每组最小值来。

你可能感兴趣的:(.net)