This one is a little tricky, I hope I can make myself clear in this issue because is not very common problem (or maybe it is?).
I have a table that have duplicate records like this (i'm talking about hundreds):
| Code|Route|State|City|Start| End|Style|
|-----------------------------------------|
| R14| 14| NL| MTY| Ind|Main| High|
| R14-01| 14| NL| MTY| Ind|Main| High|
| R15-1| 15| NL| MTY| Cal| Cle| Low|
| R15B| 15| NL| MTY| Cal| Cle| Low|
| R14-2| 14| NL| MTY| Ind|Main| High|
| RT15th| 15| NL| MTY| Cal| Cle| High|
| RT15°| 15| NL| MTY| Cal| Cle| High|
| R15.3| 15| NL| MTY| Cal| Cle| Low|
| RT15/H| 15| NL| MTY| Cal| Cle| High|
I need to get the answer like this:
| Code|Route|State|City|Start| End|Style|
|---------------------------------------|
| R14| 14| NL| MTY| Ind|Main| High|
| R15| 15| NL| MTY| Cal| Cle| Low|
| RT15| 15| NL| MTY| Cal| Cle| High|
I already create the query that group the results by Route, State, City, Start, End and Style; that was the very easy part.
SELECT DISTINCT Route, State, City, Start, End, Style FROM Routes;
If you can see the Code column is the only one that is causing problems. I need to group that column by similar Code (intersect characters and their positions R14, R14-01, R14-2 => R14 and R15-1, R15-2 => R15- and R15, R15-1 => R15)
Any idea how i can get those intersections?
To clarify the column Code is a mess, there are a lot characters that use as limitators. The table is not that short, I'm talking about thousands of records and some of them have that problem. I expanded the table a little so you can have a better view of what I'm tying to accomplish.