soil that's perfect, thank you. That query allows me to find all tickets with a specific route i.e
select * from vwFlows where ticketType = 'SDS' and
RouteCode = '150' . Yes, I was disappointed that I could not find anything to get me on a helicopter.
There are so many weird and potentially useful fares in the system that I would never have come across otherwise!
Indeed, there are many things that become trivial, e.g.,
declare @NLCCode char(4)
select @NLCCode = '0428' -- canterbury stations
select OriginDescription, DestinationDescription, Fare
, TicketTocs.Name TocName
from
(
select
OriginDescription, DestinationDescription, Fare, TicketTOCId,
ROW_NUMBER() OVER (PARTITION BY TicketTocId Order by fare asc ) as RankNr
from
vwFlows
join TicketTypes on TicketTypes.Code = VwFlows.TicketType and TicketTypes.RestrictedByTrain = 1
where OriginNLCCode = @NLCCode
or (DestinationNlcCode = @NLCCode and VwFlows.Reversable = 1)
) AS Ranked
join TicketTocs on TicketTocs.ID = TicketTOCId
where Ranked.RankNr = 1
This query returns the cheapest possible advance fares by TOC from a given origin (takes almost a minute to run on my system), in this case:
Pewsey £10.50 FGW
Corby £12 East Midlands
Rugby £12 Virgin
Bury St Edmunds £18.10 AGA
P'bo £21 EC
Dublin Ferryport £38 ATW
It doesn't guarantee availability at that price of course.
I'm currently offered for this Friday on the 09:23 from Canterbury to St Pancras
Pewsey £33.90
Corby £22
Rugby £30
BSE £25.50
PBO £66.50
Dublin Ferry Port £38 on the 07:18 or 17:25 - this appears to be a flat fare
You can increase the RankNr, to 10, which shows, inter alia, that there is a cheap Advance cluster (cheaper than to Bristol) to the Severn Beach Line routed AP Salisbury.
This results in a much cheaper fare than Pewsey, £13.30 for Friday:
CBW - Waterloo East 10:07
Waterloo - Bristol TM 12:20
Bristol TM - Severn Beach 15:16
(tickets routed St Pancras - Paddington - Bristol are also available, but they are priced over £30)