I have a database of rooms made up of Room_Widths
and Room_lengths
. I want to be able to order the dataset using a TADOQuery
in Delphi, so that the room with the longest side, whether it's the width or the length will be first in a dataset. I need this so that I can perform a bin packing algorithm on it later.
I hope, there is something that will look fairly similar to this:
ADORoomQuery.SQL.Add('ORDER BY GREATEST(Room_Width, Room_Length)');
For example if I have 3 rooms (9 x 9m), (10 x 2m) and (5 x 12m):
Room_Widths Room_Lengths
------------- -------------
9 9
10 2
5 12
Then it would return the following dataset:
Room_Widths Room_Lengths
------------- -------------
5 12
10 2
9 9
I'm using MS Access database.