I am working on a project and I have a weird requirement.
I have a table A with fields (TechID(Primary Key), Orders (INTEGER NUMBER),Name (Varchar)).
The values of Orders can be 0, 1, 2, 3, ....... My task is to display the contents of the table ordered by Orders field. rows where the Orders field has a value of 1 are displayed first, followed sequentially by the rest. rows with a value of 0 must be displayed at the end. If all the Orders field’s values are 0 I need to order the table by the TechID field.
Any ideas about achieving this ? Can this be achieved with a SQL query or should I write a T-Sql script for this ?
Didn’t actually test it, but this general idea should work:
NOTE: This assumes
Ordersis anint. If its abigintuse 9,223,372,036,854,775,807 instead.