I want to use it in the field list, (before the FROM).
This is for a proximity search and I am trying to make a scaled value to order the results by.
Example rows of table:
idLIST | Name | lat | lon | rank
1 |John's Svc| -63 | 44 | 2
2 |Ed's Svc |-63.5 | 44 | 0
So then I'd like to execute this query:
SELECT Name, lat, lon,
(distance calculations) AS dist,
(CASE rank WHEN 3 THEN dist*0 WHEN 2 THEN dist*0.02 WHEN 1 THEN dist*0.04 ELSE dist END) AS rankDist
WHERE (same distance calculations) > 50
The real query is more involved, (the distance calculations are pretty crazy, and I don't always have lat & lon values so I subquery from a ZIP code table), but that's basically what's going on.