I am asked a question in interview that sort result without using of order by clause and without using the script like php. I enough google it but did not find the way. Is there any method to sort results in this way. And it should be without using of any script like php etc.
Share
You cannot, at least not reliably.
Some SQL implementations may well return rows in the order of their primary keys or clustered indexes, but SQL itself is a relational algebra that returns arbitrarily ordered sets unless specifically told otherwise.
There’s a good chance that the order in which rows are returned may well depend on the insertion and deletion activity since the table was created.
My answer to an interview question like that would be: