Complex ORDER BY clause doesn't work

danb

Registered User.
Local time
Today, 06:39
Joined
Sep 13, 2003
Messages
98
Hi, just wondering if anyone can help me. I need to do a calculation within a query using values supplied from an ASP page, then return the results ordered by the output of that calculation (make sense??).

The query is as follows:


SELECT (([Easting]^2)+([Northing]^2)^0.5) AS CalculationResult, *
FROM Shops
WHERE (Easting>=[EastingMin_IN] AND Easting<=[EastingMax_IN] AND Northing>=[NorthingMin_IN] AND Northing<=[NorthingMax_IN])
ORDER BY (([Easting]^2)+([Northing]^2)^0.5);

I've tried ORDER BY CalculationResult, and that doesn't seem to work either!

Also, does anyone know how I would return a count of all the relevant records?

If anyone can help with this, I'd be most grateful.

Danielle
 
Select Count(*) from ....

Well count all records (if you add a where it will only count the selected records)

The Order by clause should work.... Your sure there is no further re-sorting going on the ASP display?

Regards

The Mailman
 
So does this mean I have to ask the query to do the calculation twice - once to return the records, and once to return the count?

Also, does anyone know how to get the count results back into the asp page? Forgive my lack of knowledge, I've got very little experience with SQL and queries.

Thanks again.
 

Users who are viewing this thread

Back
Top Bottom