这两段代码实现的功能相同,都是计算2021年10月份的订单平均交易金额和平均成本。不同之处在于第一段代码使用了折扣金额的计算,并且在子查询中使用了窗口函数来计算每个订单涉及的商品总价,而第二段代码直接在子查询中计算了每个订单的总价,没有使用窗口函数。另外,第一段代码中使用了abs函数计算折扣金额的绝对值,而第二段代码没有使用。

select roundsumtotal_amountcount1 as avg_amountroundsumsum_price-total_amountcount1 as avg_cost from select ouidrow_numberoverpartition by uid order by event_time asc as rsumdpricedcnt overpartition b

原文地址: https://www.cveoy.top/t/topic/gTum 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录