摘要: https://leetcode.com/articles/students-report-by-geography/ select America,Asia, Europe from ( select @row_id:=@row_id+1 as row_id, name as America fr 阅读全文
posted @ 2018-10-23 19:51 ffeng0312 阅读(461) 评论(0) 推荐(0)
摘要: https://leetcode.com/articles/average-salary-departments-vs-company/ select date_formate(pay_date,'%Y-%m') pay_month, e.department_id, (case when avg( 阅读全文
posted @ 2018-10-23 11:22 ffeng0312 阅读(265) 评论(0) 推荐(0)
摘要: https://nifannn.github.io/2017/10/27/SQL-Notes-Leetcode-614-Second-Degree-Follower/ select followee f1.follower, count(f1.follower) num from follow f1 阅读全文
posted @ 2018-10-23 10:55 ffeng0312 阅读(568) 评论(0) 推荐(0)
摘要: select min(abs(p2.x-p1.x)) shortest from point p1,(SELECT * FROM [point] order by x) p2where p1.x > p2.x 阅读全文
posted @ 2018-10-23 10:43 ffeng0312 阅读(125) 评论(0) 推荐(0)
摘要: https://leetcode.com/articles/shortest-distance-in-a-plane/ Note: To put the MIN() inside of SQRT() will slightly improve the performance. select roun 阅读全文
posted @ 2018-10-23 10:33 ffeng0312 阅读(313) 评论(0) 推荐(0)
摘要: SELECT x,y,z,(case when x+y>z and x+z>y and z+y>x then 'yes' else 'no' end) triangle FROM [triangle]; 阅读全文
posted @ 2018-10-23 10:01 ffeng0312 阅读(136) 评论(0) 推荐(0)
摘要: select id, case when p_id is null then 'Root ' when id in (select distinct p_id from tree where p_id is not null) then 'Inner' else 'leaf' end Type fr 阅读全文
posted @ 2018-10-22 11:29 ffeng0312 阅读(197) 评论(0) 推荐(0)
摘要: https://leetcode.com/articles/sales-person/ Method 1: select distinct name from salesperson where sales_id not in ( select distinct sales_id from orde 阅读全文
posted @ 2018-10-22 11:18 ffeng0312 阅读(3354) 评论(0) 推荐(0)
摘要: select distinct c1.id from cinema c1, cinema c2 where abs(c1.id-c2.id) =1 and c1.free = 1 and c2.free =1 group by c1.id 阅读全文
posted @ 2018-10-22 11:07 ffeng0312 阅读(121) 评论(0) 推荐(0)
摘要: select requester_id id, count(distinct accepter_id) num from (SELECT requester_id, accepter_id FROM [request_accepted]unionSELECT accepter_id, request 阅读全文
posted @ 2018-10-22 10:55 ffeng0312 阅读(158) 评论(0) 推荐(0)