Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 Ordering by a calculated field

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2001-05-28 : 09:40:54
Mike writes "I've got an ASP project that I am working on and have the following code snippet:

Response.Write "<TABLE BORDER=1 CELLPADDING=6 CELLSPACING=1 WIDTH=730 align=center>"
Response.Write "<TR>"
Response.Write "<TD align=center>ZipCode</TD>"
Response.Write "<TD align=center>City</TD>"
Response.Write "<TD align=center>Distance (Miles)</TD>"
Response.Write "</TR>"
while not ZP2.EOF

If ZP1("zip") = ZP2("zip") Then
miles = 0
Else
miles=SQR(.1*((ZP1("V")-ZP2("V"))^2 + (ZP1("H")-ZP2("H"))^2))
end if
if miles <= csng(radius) then
Response.Write "<TR>"
Response.Write "<TD align=center>" & ZP2("Zip") & "</TD>"
Response.Write "<TD align=center>" & ZP2("Location") & "</TD>"
Response.Write "<TD align=center>" & FormatNumber(miles, 2) & "</TD>"
Response.Write "</TR>"

I'm calculating miles on the fly through the recordset loop.
Is there a that I can move that calculation to my SQL statement and have the results ordered by miles asc?

Thanks in advance for the help. This is in SQL 7.0 SP2, NT SP6.

--Mike"
   

- Advertisement -