SQL每日一题(20220531)
select order_id, count(1) cnt
from (
select order_id
from t1123
union all
select customer_id
from t1123) a
group by order_id
having cnt in (select max(cnt)
from (
select order_id, count(1) cnt
from (
select order_id
from t1123
union all
select customer_id
from t1123) a
group by order_id
) a)
select n.customer_id
from (select COUNT(customer_id) 数量, customer_id from T1123 group by customer_id) n
where n.数量 = (select MAX(数量) from (select COUNT(customer_id) 数量, customer_id from T1123 group by customer_id) m)
select customer_id
from (select customer_id, rank() over (order by t desc) r
from (select customer_id, count(1) t from T1123 group by customer_id) a) b
where b.r = 1;