我想找出所有同一所学校超过1份订单的学校。在下面的例子中,我想找到2号学校
&c-&b=4
查询应该是这样的:
| school_ucn | order_no |
-----------------------------
| 1 | 101 |
| 1 | 101 |
| 2 | 102 |
| 2 | 102 |
| 2 | 103 |
| 2 | 103 |
答案 0 :(得分:3)
从你的小组中取出订单号
select
school_ucn,count(DISTINCT otc_order_number)
from
storiacloud.schl_storia_revenue_fact
group by
school_ucn
having
count(distinct otc_order_number)>1