You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Give the id and the name for the stops on the '4' 'LRT' service.
SELECT id, name
FROM stops
JOIN route
ON id = stop
WHERE num ='4'AND company ='LRT'
Find routes that visit either London Road (149) or Craiglockhart (53) and have more than 2 counts
SELECT company, num, COUNT(*)
FROM route
WHERE stop=149OR stop=53GROUP BY company, num
HAVINGCOUNT(*) >1
Use a Self-join to find the start stop as Craiglockhart and end stop as London Road
SELECTa.company, a.num, a.stopAS start, b.stopAS end
FROM route AS a
JOIN route AS b
ONa.num=b.numWHEREa.stop=53andb.stop=149
Give a list of all the services which connect stops 115 and 137 ('Haymarket' and 'Leith')
SELECT DISTINCTa.company, a.numFROM route AS a
JOIN route AS b ON (a.num=b.num)
WHEREa.stop=115ANDb.stop=137
Give a list of the services which connect the stops 'Craiglockhart' and 'Tollcross'
SELECT DISTINCTa.company, a.numFROM route AS a
JOIN route AS b
ONa.num=b.numJOIN stops AS sa
ONsa.id=a.stopJOIN stops AS sb
ONsb.id=b.stopWHEREsa.name='Craiglockhart'ANDsb.name='Tollcross'