This will take some explaining so bear with me.
The file, projections, has 56,037 rows. There are 29 columns but only two are really all that relevant. The main purpose of this is to organize the data in a certain way. There, my end result should have 56,037 rows.
The two fields of relevance are occ_code and indcode. At the moment, what I am doing in excel is filtering and then copying and pasting to a new tab. First, I filter by occ_code in ascending order and then by a field titled Trailing. Trailing is a calculated field based on the number of trailing zeros (111000, therefore 3) in the indcode column. I do this 4 times, for trailing values 2,3,4, and 6. From there, I sort by the results by indcode in ascending order. To give this some concreteness, the data and an end result are given below.
**Original unsorted**
indcode occ_code
000000 000000
441000 110000
123000 231000
102000 148000
102800 254000
361000 000000
102700 111011
**Intended result**
indcode occ_code
000000 000000
361000 000000
441000 110000
102700 111011
102000 148000
123000 231000
102800 254000
I need the query to return the entire row not just occ_code and/or incode. My first question is to how to have it select all by distinct values of occ_code. From there how to have it order the results of that by trailing and then indcode.
I tried the following but it was unsuccessful.
Select Occ_code, indcode From dbo.projections group by Occ_code, indcode Order by occ_code asc, trailing
asc
↧