1

In writing a query using CTE I am trying to order all the various levels of child elements which are of a certain data type. Within the database there is a "display order" column which I have used to extract the parent display order and concatenate it to the childrens' display order. The resulting column is an array of items of mixed length which show from parent to child what the upper level display order is, see below:

DISPLAYORDER
10-0
11-0
12-0
13-0
2-0-0
2-1-2-0
2-1-3-0
2-1-4-0
3-1
3-2
3-2-4-0
4-0-1
4-1-1
4-2-0
4-3-0
4-4-0
5-0
6-0
7-0
8-0
9-0

The above data has been sorted by order, but unfortunately because I had to convert from int to varchar in order to concatenate, I have reintroduced the "1,10,11,2" issue that can happen in trying to sort. Is there a workaround I can use when sorting to move the top four rows (10-0 through 13-0) to the bottom?

KyleRM
  • 13
  • 2

1 Answers1

0

Left Pad your numbers with zero such that 2-1-2-0 becomes 02-01-02-00, If you have ordinals greater than 99 pad to three characters wide, 002-001-002-000

Sentinel
  • 6,379
  • 1
  • 18
  • 23