1. 程式人生 > >SQL: 某個時間段範圍內,產品有價格,且求平均數

SQL: 某個時間段範圍內,產品有價格,且求平均數

having end case 產品 天數 logs style where and

select ID,AVG(fPrice) as avgPrice from Price
where Hp_Date >=2017-07-04 and  Hp_Date <=2017-07-06
group by ID
having SUM(case when ISNULL(fPrice,0) > 0 and Status=0 then 1 else 0 end)=天數

SQL: 某個時間段範圍內,產品有價格,且求平均數