selectround(sum(order_date=customer_pref_delivery_date)/count(1)*100,2) immediate_percentagefrom (select*,row_number() over(partitionby customer_id order by order_date) rkfrom Delivery) twhere rk=1
subquery
selectround(sum(if(order_date=customer_pref_delivery_date,1,0))/count(distinct customer_id)*100,2) immediate_percentagefrom Deliverywhere (customer_id, order_date) in (select customer_id, min(order_date) from Deliverygroup by customer_id);