William
|
| Posted: 02/15/2002, 7:39 AM |
|
I have a database that displays branch details, it displays one record at a time, how can i display a certain record first everytime this asp is loaded?
Thanks in advance
|
|
|
 |
Ken Hardwick
|
| Posted: 02/15/2002, 9:59 AM |
|
Not sure if I this is what you are looking for..but.
You can use a custom SQL statement so that the one record that you want to show first would always be returned first.
I wrote the following in order to get dynamic list boxes that I was using to sort the value being updated (being pasted as a parameter) would always be the first one shown in a list box.
Below are examples for three different databases.
And, of course, the value could be hard coded instead of being passed as a variable.
Like for example..
decode("field1,'Hardwick',0,1) as TheSort
then row(s) with "Hardwick" in field1 would have a value in "TheSort" as 0
and all other rows would have a value of 1. Then if you sorted (asc) by "TheSort", then that row (or those rows) would be returned first.
Hope thishelps...Ken@kenhardwick.com
'Oracle
Select distinct Field1,Field2
,decode(Field1,'" & getparam("field1") & "',0,1) as TheSort
from A_Table
Order by TheSort,Field1
'SQL Server Example
sql = ""
sql = sql & " SELECT Tasks.Task_id,Tasks.Milestone, "
sql = sql & " CASE WHEN Tasks.Task_id = '" & GetParam("Task_id")& "' THEN 1 ELSE 2 END AS Val1"
sql = sql & " FROM Tasks "
sql = sql & " Where Tasks.activity_id = '" & rs(0) & "'"
sql = sql & " order by val1,Tasks.milestone asc"
'Access97
select Milestone_ID as Prj_Milestone,Milestone as name from [prj_milestones] where project_id= '" & rs(0) & "' order by iif(Milestone_ID= " & GetParam("Prj_Milestone") & " ,0,1),milestone asc")
|
|
|
 |
|