3
我想找出所有同一學校有1個以上訂單的學校。在下面的例子中,我想找到學校沒有2尋找有1個以上訂單的學校
| school_ucn | order_no |
-----------------------------
| 1 | 101 |
| 1 | 101 |
| 2 | 102 |
| 2 | 102 |
| 2 | 103 |
| 2 | 103 |
如果查詢是這樣的:
select
school_ucn, count(otc_order_number)
from storiacloud.schl_storia_revenue_fact
group by
otc_order_number, school_ucn
having count(otc_order_number) > 1
我會用'COUNT(DISTINCT otc_order_number)',基於OP的期望輸出。 –
修改了@FelixPamittan正確提示的答案。 TX – Adish