ASP - Sort By a Calculation??

G

gjoneshtfc

Hello,

I have an asp page that is a table. In the table the end column is a
calculation of other values, for example:

<%=(RS1.Fields.Item("Won").Value)+(RS1.Fields.Item("Drawn").Value)+(RS1.Fields.Item("Lost").Value)%>

To be complete: this is placed in the table instead of
RS1.Fields.Item("Played").Value

My question is it is possible to sort by this calculated value. It has
to be calculated as the contents of this column in the access table is
always 0. This is because this value is calculated in a form in access
and cannot be saved in the table due to data corruption. I do not mind
that because I can calculate the value on the asp page anyway as above
- it is just the sorting that I need to get right now!

Thanks in advance for your help,
Gareth
 
B

Bob Barrows [MVP]

Hello,

I have an asp page that is a table. In the table the end column is a
calculation of other values, for example:

<%=(RS1.Fields.Item("Won").Value)+(RS1.Fields.Item("Drawn").Value)+(RS1.
Fields.Item("Lost").Value)%>

To be complete: this is placed in the table instead of
RS1.Fields.Item("Played").Value

My question is it is possible to sort by this calculated value. It has
to be calculated as the contents of this column in the access table is
always 0. This is because this value is calculated in a form in access
and cannot be saved in the table due to data corruption. I do not mind
that because I can calculate the value on the asp page anyway as above
- it is just the sorting that I need to get right now!

Thanks in advance for your help,
Gareth

Do the calculation in the sql statement used to open the recordset. Use
the calculation in the ORDER BY clause as well.

sql = "select Won, Drawn, Lost, Won + Drawn + Lost as Total " & _
"FROM ... ORDER BY Won + Drawn + Lost"
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,774
Messages
2,569,598
Members
45,145
Latest member
web3PRAgeency
Top