Hi,
I posted a similar question yesterday but have since thought of a more general way to describe the problem.
What is the best way to sort rows of data when some of the columns have to be calculated by hand. That is, the user is presented with a table of data which they can then select by which column they wish to sort by.
The problem of the above being that some of the columns i created manually (and are therefore not in the database) and so a simple ORDER BY clause cannot be used in the original SELECT.
How do you handle this? I was thinking I could either make some form of temporary database, calculating the extra desired fields and THEN pulling the data. This seems rather long-winded. My other thought was to get as much as I could from the database, calculate the extra stuff and store each row in a class. Then I could use a general sorting algorithm to sort the objects into whatever order I required based on the desired sorting column. If there are thousands of rows, though, will this cause problems? I realise it depends on the machine.
Other than above I can't think of another way to achieve this, I don't think the database can be 'redesigned' to suit what I am looking for. My only other option is to not allow 'ordering by' on columns which I have generated by hand. But this is not desirable since most of the good stuff is in those columns.
Anyway, I hope I have explained this OK, I really do appreciate any advice you gurus have to offer.
Thanks and regards,
Russ.