一、题目
二、代码
select round(100*sum(case when table1.order_date = table1.customer_pref_delivery_date then 1 else 0 end ) /count(distinct table1.customer_id ),2) as immediate_percentage
from Delivery as table1
join
(
select customer_id ,min(order_date ) as min_date from Delivery
group by customer_id
) as table2
where table1.customer_id = table2.customer_id
and table1.order_date = table2.min_date