1
我在創建一個2列的表。 1列包含每個月支付的金額,而另一列包含訂購當月並支付該月份的客戶數量。在計數函數中使用where子句
select sum(paid), count(distinct customer where Order_Month = Paid_Month)
from DataTable
group by Paid_Month
有沒有簡單的方法呢?
我在創建一個2列的表。 1列包含每個月支付的金額,而另一列包含訂購當月並支付該月份的客戶數量。在計數函數中使用where子句
select sum(paid), count(distinct customer where Order_Month = Paid_Month)
from DataTable
group by Paid_Month
有沒有簡單的方法呢?
使用case
表達:
select sum(paid),
count(distinct case when Order_Month = Paid_Month then customer end)
from DataTable
group by Paid_Month;