由买买提看人间百态

boards

本页内容为未名空间相应帖子的节选和存档,一周内的贴子最多显示50字,超过一周显示500字 访问原贴
JobHunting版 - 求助一道sql问题,谢谢
相关主题
贴个电话面试经历,攒点人品OPT service center
2个offer如何选, 大家帮帮忙Internship position: Routing in wireless mesh networks
OPT申请, G-1145有用么?Internship at MERL: Routing for wireless mesh networks
My OPT case为什么OPT申请从TSC转到VSC去了?
OPT申请,有人比我更背么?请教:我的OPT材料寄的是Dallas,为啥被转到Vermont了
求助关于OPT的几个小问题网申状态显示route是什么意思
My OPT case (VSC)Thoughtworks code assessment, aptitude paper.
amazon两轮电面后杯具Cisco友情refer
相关话题的讨论汇总
话题: join话题: stops话题: route话题: sighthill
进入JobHunting版参与讨论
1 (共1页)
j******g
发帖数: 63
1
结果跟标准答案不一样。。。
http://sqlzoo.net/wiki/Self_join
表格基本信息:
stops(id, name)
route(num,company,pos, stop)
1) 大体上company+num合在一起算是一条线路的unique key。
2) route.stop跟stop.id相合
题目:
Find the routes involving two buses that can go from Craiglockhart to
Sighthill.
Show the bus no. and company for the first bus, the name of the stop for the
transfer,
and the bus no. and company for the second bus.
给的提示:
Self-join twice to find buses that visit Craiglockhart and Sighthill, then
join those on matching stops.
我的sql code
SELECT a.num, a.company, stopb.name, d.num, d.company
FROM
route a
JOIN route b ON
(a.company=b.company AND a.num=b.num and a.stop<>b.stop)
JOIN route c ON
(b.stop=c.stop)
JOIN route d on
(c.company=d.company AND c.num=d.num and c.stop<>d.stop)
JOIN stops stopa ON (a.stop=stopa.id)
JOIN stops stopb ON (b.stop=stopb.id)
JOIN stops stopc ON (c.stop=stopc.id)
JOIN stops stopd ON (d.stop=stopd.id)
WHERE stopa.name='Craiglockhart' and stopd.name='Sighthill' and (a.num<>d.
num or a.company<>d.company);
1 (共1页)
进入JobHunting版参与讨论
相关主题
Cisco友情referOPT申请,有人比我更背么?
问一道题 from orbitz求助关于OPT的几个小问题
Juniper Networks 招软件开发intern,或full timeMy OPT case (VSC)
Apple on-site 求教amazon两轮电面后杯具
贴个电话面试经历,攒点人品OPT service center
2个offer如何选, 大家帮帮忙Internship position: Routing in wireless mesh networks
OPT申请, G-1145有用么?Internship at MERL: Routing for wireless mesh networks
My OPT case为什么OPT申请从TSC转到VSC去了?
相关话题的讨论汇总
话题: join话题: stops话题: route话题: sighthill