SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


query for routing


query for routing

Author
Message
fbrewer
fbrewer
Forum Newbie
Forum Newbie (4 reputation)Forum Newbie (4 reputation)Forum Newbie (4 reputation)Forum Newbie (4 reputation)Forum Newbie (4 reputation)Forum Newbie (4 reputation)Forum Newbie (4 reputation)Forum Newbie (4 reputation)

Group: General Forum Members
Points: 4 Visits: 10
I have a table called flights with columns: fltNum, departureCity, depTime, arrivalCity, arrTime

I want to query flights and produce an out put table that depicts the routing from a takeoff city and a land city.

I will designate a no earlier than takeoff time, and a no later than land time. I will also designate a minimum of 30 minutes between connections, and a maximum of 3 flights.

The output row header is:

flt depCity 1 depTime 1 arrCity 1 arrCity 1 flt 2 depCity 2 depTime 2 arrCity 2 arrCity 2 ............ arrCity 3

The output will display non-stop flights, 2-flight routings, and 3-flight routings

Any suggestions of creating the query are appreciated.
dwain.c
dwain.c
SSCoach
SSCoach (18K reputation)SSCoach (18K reputation)SSCoach (18K reputation)SSCoach (18K reputation)SSCoach (18K reputation)SSCoach (18K reputation)SSCoach (18K reputation)SSCoach (18K reputation)

Group: General Forum Members
Points: 18237 Visits: 6431
To get a working query out of the volunteers on this forum, you'll need to provide more in the way of DDL and consumable sample data. This article explains how: Forum Etiquette: How to post data/code on a forum to get the best help.

But I may be able to help you out a bit. Take a look at this recent article: Departures from Origins and Arrivals at Destinations.

The data structures should be quite similar and it is quite likely that some of the queries may be adaptable to your needs. Note that it is just a starting point though. The article clearly states that it is not meant to be the all singing, all dancing solution to the problem. For example, it doesn't provide the query to generate connecting flights as you've advised you wanted, however it is very likely to be possible to generate that from the data structure provided.

I should also mention that the data structure you've proposed is going to be incomplete on several points, but reading the article should illuminate at least some of these.

Let me know if this helps.


My mantra: No loops! No CURSORs! No RBAR! Hoo-uh!

My thought question: Have you ever been told that your query runs too fast?

My advice:
INDEXing a poor-performing query is like putting sugar on cat food. Yeah, it probably tastes better but are you sure you want to eat it?
The path of least resistance can be a slippery slope. Take care that fixing your fixes of fixes doesn't snowball and end up costing you more than fixing the root cause would have in the first place.


Need to UNPIVOT? Why not CROSS APPLY VALUES instead?
Since random numbers are too important to be left to chance, let's generate some!
Learn to understand recursive CTEs by example.
Splitting strings based on patterns can be fast!
My temporal SQL musings: Calendar Tables, an Easter SQL, Time Slots and Self-maintaining, Contiguous Effective Dates in Temporal Tables
fbrewer
fbrewer
Forum Newbie
Forum Newbie (4 reputation)Forum Newbie (4 reputation)Forum Newbie (4 reputation)Forum Newbie (4 reputation)Forum Newbie (4 reputation)Forum Newbie (4 reputation)Forum Newbie (4 reputation)Forum Newbie (4 reputation)

Group: General Forum Members
Points: 4 Visits: 10
dwain,

Thanks for your post. I will consume it over the next few days and will report back.
dwain.c
dwain.c
SSCoach
SSCoach (18K reputation)SSCoach (18K reputation)SSCoach (18K reputation)SSCoach (18K reputation)SSCoach (18K reputation)SSCoach (18K reputation)SSCoach (18K reputation)SSCoach (18K reputation)

Group: General Forum Members
Points: 18237 Visits: 6431
fbrewer (1/2/2013)
dwain,

Thanks for your post. I will consume it over the next few days and will report back.


I was just wondering if you had any luck with this.


My mantra: No loops! No CURSORs! No RBAR! Hoo-uh!

My thought question: Have you ever been told that your query runs too fast?

My advice:
INDEXing a poor-performing query is like putting sugar on cat food. Yeah, it probably tastes better but are you sure you want to eat it?
The path of least resistance can be a slippery slope. Take care that fixing your fixes of fixes doesn't snowball and end up costing you more than fixing the root cause would have in the first place.


Need to UNPIVOT? Why not CROSS APPLY VALUES instead?
Since random numbers are too important to be left to chance, let's generate some!
Learn to understand recursive CTEs by example.
Splitting strings based on patterns can be fast!
My temporal SQL musings: Calendar Tables, an Easter SQL, Time Slots and Self-maintaining, Contiguous Effective Dates in Temporal Tables
fbrewer
fbrewer
Forum Newbie
Forum Newbie (4 reputation)Forum Newbie (4 reputation)Forum Newbie (4 reputation)Forum Newbie (4 reputation)Forum Newbie (4 reputation)Forum Newbie (4 reputation)Forum Newbie (4 reputation)Forum Newbie (4 reputation)

Group: General Forum Members
Points: 4 Visits: 10
Dwain,

I have an initial stab at an algorithm for my particular purpose, but unfortunately, I have too many other responsibilities to move this forward at this time.

I will definately share my work when I have done so.

Thanks for asking
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search