You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Source : https://leetcode.com/problems/immediate-food-delivery-i/
Author : liuyubobobo
Time : 2022-04-25
Using Nested Query
SELECT
ROUND(
(SELECTCOUNT(*) FROM Delivery WHERE order_date = customer_pref_delivery_date) /
(SELECTCOUNT(*) FROM Delivery) *100.0, 2) AS immediate_percentage
FROM Delivery LIMIT1
Using SUM for bool result (NOT COUNT)
SELECT ROUND(SUM(order_date = customer_pref_delivery_date) *100.0/COUNT(delivery_id), 2) AS immediate_percentage
FROM Delivery
Using AVG
SELECT ROUND(AVG(order_date = customer_pref_delivery_date) *100.0, 2) AS immediate_percentage
FROM Delivery