SQL笔试

--Basic facts gathering
--1.
--按每辆单车的使用用户数排序,没有被使用的次数none排在最后
SELECT b.id, t.u_num
FROM bikes b
LEFT JOIN (
SELECT bike_id, COUNT(DISTINCT user_id) AS u_num
FROM trips
WHERE started_at >= '2017-06-01'
AND completed_at <= '2017-06-30' AND status = 'completed' GROUP BY bike_id ) t ON b.id = t.bike_id ORDER BY t.u_num DESC --按每辆单车的trip次数排序,没有trip的none排在最后 SELECT b.id, t.num FROM bikes b LEFT JOIN ( SELECT bike_id, COUNT(1) AS num FROM trips WHERE star

SQL笔试最先出现在Python成神之路

版权声明:
作者:siwei
链接:https://www.techfm.club/p/4547.html
来源:TechFM
文章版权归作者所有,未经允许请勿转载。

THE END
分享
二维码
< <上一篇
下一篇>>