Solution. No Zero counting. Pure SQL Code


  • 0
    W

    Solution without including dates with 0 rates. Please modify the script for it to include Zeros ;)

    SELECT q.Request_at AS Day, FORMAT(q.num/p.num, 2) AS Cancellation_Rate
    From ( SELECT Request_at, COUNT() AS num
    FROM Trips t
    WHERE (NOT EXISTS(SELECT b.Users_idFROM Users b
    WHERE b.Users_id = t.Client_id AND t.Request_at > '2013-10-01' AND t.Request_at < '2013-10-03' AND b.Role = 'YES') )GROUP BY Request_at) AS p,(SELECT Request_at, COUNT(
    ) AS num FROM Trips t WHERE (NOT EXISTS(SELECT b.Users_id FROM Users b WHERE b.Users_id = t.Client_id AND t.Request_at > '2013-10-01' AND t.Request_at < '2013-10-03' AND b.Role = 'YES') AND t.status = 'ca')GROUP BY Request_at) AS q WHERE q.Request_at = p.Request_at;


Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.