Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

sql "as"

Status
Not open for further replies.
Jul 7, 2003
95
US
Should the field distance be populated with a number from the following statement (as distance)? All I get is 0.000 All the other data is fine and seems correct. Just dont get the distance.


SELECT *, ROUND((ACOS((SIN(val(passedzip.latitude)/57.2958) * SIN(val(passedzip.latitude)/57.2958)) + (COS(val(passedzip.latitude)/57.2958) * COS(val(passedzip.latitude)/57.2958) * COS(val(passedzip.longitude)/57.2958 - val(passedzip.longitude)/57.2958)))) * 3963,3)^2;
AS distance;
FROM automaster;
WHERE (val(latitude) >= val(passedzip.latitude) - (passedradius/111));
And (val(latitude) <= val(passedzip.latitude) + (passedradius/111));
AND (val(longitude) >= val(passedzip.longitude) - (passedradius/111));
AND (val(longitude) <= val(passedzip.longitude) + (passedradius/111));
ORDER BY zip
 
Since nothing changes in your expression Round((....,3)^2 if it calculates to zero, then all will be 0.00. Don't you want to use something from automaster ano passedzip?

Rick
 
In SQL the returned data field width and decimals takes its cue from the 1st returned value. Try adding a format by adding '0' as you'd like your output to be:

SELECT *, ;
(ROUND((ACOS((SIN(val(passedzip.latitude)/57.2958) * ;
SIN(val(passedzip.latitude)/57.2958)) + ;
(COS(val(passedzip.latitude)/57.2958) * ;
COS(val(passedzip.latitude)/57.2958) * ;
COS(val(passedzip.longitude)/57.2958 - ;
val(passedzip.longitude)/57.2958)))) * ;
3963,3)^2)+00000.000 AS distance;
FROM automaster;
WHERE (val(latitude) >= val(passedzip.latitude) - (passedradius/111));
And (val(latitude) <= val(passedzip.latitude) + (passedradius/111));
AND (val(longitude) >= val(passedzip.longitude) - (passedradius/111));
AND (val(longitude) <= val(passedzip.longitude) + (passedradius/111));
ORDER BY zip
 
actually, the whole program now seems not to work. I think its moot. wish I had your guys smarts.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top