What if you had a related table with your key, state and relation columns. In the relations column you would have 4 chars, the first two are the state, the next two are the bordering state. Tennessee would have something like the following:
Key State relation 1 TN TNAR 1 TN TNMS 1 TN TNMO 1 TN TNKY 1 TN TNNC 1 TN TNVA 1 TN TNAL 1 TN TNGA I believe this will allow you to pull surrounding states. John -----Original Message----- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Frank Burcaw Sent: Monday, June 26, 2006 1:18 PM To: [email protected] Subject: Interesting SQL Puzzle Here's a tough one that I could use help with. I need to sum /.group a set of records based on if the States (Nebraska, Arizona, New York), border one another or if a chain of bordering States can be found. So for example, NE $100.00 IA $100.00 IL $100.00 TX $200.00 AZ $350.00 CA $350.00 Group one is $300.00 (NE, IA, IL) - NE borders IA, IA borders IL - a chain Group two is $200.00 (TX) - TX does not border any of other states Group three is $700.00 (AZ, CA) - AZ borders CA Smells like a hierarchical query, but I'm not sure. Also need to be able to assign a group number / designation to the individual records. Anyone dealt with this before? -- [EMAIL PROTECTED] www.mymacaronilife.com [excessive quoting removed by server] _______________________________________________ Post Messages to: [email protected] Subscription Maintenance: http://leafe.com/mailman/listinfo/profox OT-free version of this list: http://leafe.com/mailman/listinfo/profoxtech ** All postings, unless explicitly stated otherwise, are the opinions of the author, and do not constitute legal or medical advice. This statement is added to the messages for those lawyers who are too stupid to see the obvious.

