Quantcast
Channel: Microsoft SQL Server
Viewing all articles
Browse latest Browse all 4871

Sorting in SQL

$
0
0

I have a table in SQL Server that has an item number that I need to be able to sort by. The item numbers could be something like10, 91, 94, 95 (these ones are fairly easy to sort) however I am stuck when the numbers come through like:

The correct sequence should be 1, 1.3.1, 1.3.1.1, 1.3.1.2, 1.3.2, 1.3.10, HCV1001

I can get the query to work if the I don't have anything HCV1001 using the Hierarchy ID datatype, but this fails when using something that starts with a letter. The problem I have is that these numbers can vary from project to project and are generated through an applications


Viewing all articles
Browse latest Browse all 4871

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>