Sorting on an evaluated field

taufoofah

New member
Joined
Aug 3, 2005
Messages
1
Programming Experience
Beginner
Hi all, I am encountering a problem and would appreciate that someone could share their ideas with me.

I have a datagrid which will always show Top 20 records queried from the database and from the datagrid, I have 2 evaluated column, which is calculated on the fly base on the return recordset. (It's something like the Excel, Column 1 * Column 5). I have a class which can cater the mathematical evaluation but the problem is, i'm not able to sort that evaluated column (i would name it as a formula column).

Is there a way that I can sort on the formula column? Bare in mind that the sorting function will also cater for all the records in the database, which means, if the database is having 100 records, the sorting will be comparing all the 100 records, instead of just the 20 records.

Hope that someone will be able to give me some suggestions. By the way, it's my first time posting and I'm a beginner and I would like to apologise if my question is not clearly expressed

Thousands of thankyous.....
 
Database Query

You say 'Top 20 records queried from the database', do you create the formula fields in the query? Do you actually query the 'top' 20 records as in "Select top 20"? What is your database, what is your select statement? A good look at the select statement will help us see what you are doing. Could be as simple as adding the formula fields to the select statement and then using 'order by'.
Stored Procedures might be worth looking into also.


"SELECT [FIELD 1], [FIELD 2], [FIELD 1] * [FIELD 2] AS FORMULA FROM TABLE1 ORDER BY [FIELD 1] * [FIELD 2]"
 
Last edited:
Back
Top