聚合函數分組

使用group by分組時如果需要顯示幾個屬性值就要在分組中加入

select b.property_name,b.variety, sum(a.whole_num) from tb_stock a, td_product_property b where a.property_id = b.property_id group by b.property_name,b.variety,b.product_info_id

但如果要統計按某一屬性的合計時則要使用下列的方法
select b.property_name,b.variety, sum(a.whole_num) over (partition by b.product_info_id)
from tb_stock a, td_product_property b
where a.property_id = b.property_id
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章