This topic is locked
[SOLVED]

 Rank Records On List Page

5/22/2013 9:59:07 PM
ASPRunnerPro General questions
lefty author

I am using AspRunner 7.2 / Access Database
I have a table that displays rank by results of another field. I have the following query on table below.
SELECT (SELECT count(*) + 1 from Cup where cuppts > T.cuppts) AS Rank, T.cuppts, T.fldlast, T.LastUpdated, T.ID

FROM Cup AS T

ORDER BY T.cuppts Desc
T is a temporary table.
Problem is because the field cuppts is a text field. I am getting results like for example
cuppts / Rank

8 / 1

7 / 3

7 / 3

6 / 4

1 / 5

11 / 5< this is the problem . Since text field cannot sort numbers I need to get leading zeros in single digit numbers for it to show as Rank of 1st.The cuppts field is calculated in an update and/or add statement in another table after delete event.
ex.

set dal_table=dal.Table("Cup")

dal_table.cuppts=deleted_values("cuppts")

dal_table.fldlast=deleted_values("fldlast")

dal_table.LastUpdated=deleted_values("flddate")

dal_table.Add()
and/or update statement.
sql="update Cup set cuppts=(IIF(ISNULL(cuppts),0,cuppts) + " & deleted_values("cuppts") & " ) Where fldlast IN (Select fldlast from Cup where fldlast = '" & deleted_values("fldlast") & "')"

customQuery(sql)
I have tried making this a numeric field in all my tables but it will not properly add decimals when viewing on list page in my other table. Have tried settin to 4 deimal places but shows ex. 4.0000 when it should be 4.4445. for example.I also tried formatNumber statement but also incorrect decimals . It rounds up in some case down in others. In some cases .50 shows as O.0000 So Hence the text field.
Anyone Ideas appreciated.

Sergey Kornilov admin 5/24/2013

Try the following order by:

ORDER BY CDbl(t.cuppts) desc



More info on conversion functions:

http://office.microsoft.com/en-us/access-help/type-conversion-functions-HA001229018.aspx

lefty author 5/24/2013



Try the following order by:

ORDER BY CDbl(t.cuppts) desc



More info on conversion functions:

http://office.microsoft.com/en-us/access-help/type-conversion-functions-HA001229018.aspx



Thanks Again . Got it working properly.
Here is the sql I used.
SELECT (SELECT count(*) + 1 from Cup where CDbl(cuppts) > CDbl(T.cuppts))AS Rank, CDbl(T.cuppts), T.fldlast, T.LastUpdated, T.ID

FROM Cup AS T

ORDER BY CDbl(T.cuppts) Desc See Final Notes Below
For those of you who use this .. Remember to take out the Number Validation in visual editor of the field cuppts. as this will give unexpected results. otherwise it works fine . so far.
Here is the final link to see it in action : Total Cupoints and Rank ( using text field )

lefty author 5/24/2013



Thanks Again . Got it working properly.
Here is the sql I used.
SELECT (SELECT count(*) + 1 from Cup where CDbl(cuppts) > CDbl(T.cuppts))AS Rank, CDbl(T.cuppts), T.fldlast, T.LastUpdated, T.ID

FROM Cup AS T

ORDER BY CDbl(T.cuppts) Desc
For those of you who use this . If you want to add decimals in visual editor.view as a number only and edit as text only with no validation. Remember to add the decimals points to the right .
I suggest this be moved over to Tips And Tricks. This can be helpfull to some members.
Here is the final link to see it in action : Total Cupoints and Rank ( using text field )