异步,永不止步

【Leetcode-Mysql】Trips and Users

思路不总结了,看过题目自己尝试过之后,看下方代码应该能理解的

SELECT
	Request_at AS DAY,
	round(
		sum(
			CASE
			WHEN STATUS = 'completed' THEN
				0
			ELSE
				1
			END
		) / count(Id),
		2
	) AS 'Cancellation Rate'
FROM
	Trips
WHERE
	Client_Id IN (
		SELECT
			Users_Id
		FROM
			Users
		WHERE
			Banned = 'NO'
		AND Role = 'client'
	)
AND Request_at >= '2013-10-01'
AND Request_at <= '2013-10-03'
GROUP BY
	Request_at;

  

posted on 2016-05-30 17:20  gaopq  阅读(186)  评论(0编辑  收藏  举报

导航