multiple sorting order

Having for example a temporary table TempTable in which I have (among others) 2 columns , Column1 and Column2 as Decimal how can I have it sorted simultaneously by Column1 in ascending order and Column2 in descending order?

Welcome to DUG

You can take 2 same dataitems and sort them as you want and Insert the values into 3rd same dataitem one by one.

That’s not a bad thought Mohana, but I think NAV will re-sequence the records as you insert them into the 3rd dataitem based on the primary key, which will defeat the purpose of the exercise. To get around that, you would need to create another table object, defined exactly the same as the source table with the exception of the addition of a new field (“Entry No.”) and changing the primary key from Field1,Field2 to “Entry No.” and will have the effect of sorting the records by ascending Field1, descending Field2. The downer is that you’ve got to write code to populate the target data item and manage whatever the user does with it so that they’re acting on the source table and not this temporary sorting table.

I’ve never really considered this issue before now. This kind of sort is easy pickin’s for Excel. Seems like there ought to be a cleaner way of doing it in NAV. This will be my lunch 'n learn topic for today.


Thank you for your points.

I didnt try this but thought it should work

lets say table 1 has following fields

1 20

2 40

3 60

where 1,2,3 are primary key fields

table 2 has

1 200

2 150

3 100

we can insert above 2 tables into 3rd table as

1 20 200

2 40 150

3 60 100

will it work or not?

good morning sir,

ya mohana it was working


Thanks for replies,

I miss more and more the power of simple SQL sintax, I hate scratching my left ear with my right hand.