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.
| Author |
Topic |
|
jrockfl
Posting Yak Master
223 Posts |
Posted - 2005-08-10 : 11:30:11
|
| I'm getting an error with this query, Round requires 2 or 3 arguments, anyone see what's wrong?SELECT ROUND(ACOS(SIN(27.846419 / 57.2958) * SIN(LATITUDE / 57.2958) + COS(27.846419 / 57.2958) * COS(LATITUDE / 57.2958) * COS(LONGITUDE / 57.2958 - - (082.301249 / 57.2958))) * 3963) AS distanceFROM ZipCodes |
|
|
Seventhnight
Master Smack Fu Yak Hacker
2878 Posts |
Posted - 2005-08-10 : 11:34:13
|
quote: From BOLSyntaxROUND ( numeric_expression , length [ , function ] ) Argumentsnumeric_expressionIs an expression of the exact numeric or approximate numeric data type category, except for the bit data type.lengthIs the precision to which numeric_expression is to be rounded. length must be tinyint, smallint, or int. When length is a positive number, numeric_expression is rounded to the number of decimal places specified by length. When length is a negative number, numeric_expression is rounded on the left side of the decimal point, as specified by length.functionIs the type of operation to perform. function must be tinyint, smallint, or int. When function is omitted or has a value of 0 (default), numeric_expression is rounded. When a value other than 0 is specified, numeric_expression is truncated.
So try:SELECT ROUND(ACOS(SIN(27.846419 / 57.2958) * SIN(LATITUDE / 57.2958) + COS(27.846419 / 57.2958) * COS(LATITUDE / 57.2958) * COS(LONGITUDE / 57.2958 - - (082.301249 / 57.2958))) * 3963,2) AS distanceFROM ZipCodes Corey Co-worker on The Wizard of Oz "...those three midgets that came out and danced, the freaked me out when I was little. But they are ok now." |
 |
|
|
jrockfl
Posting Yak Master
223 Posts |
Posted - 2005-08-10 : 11:40:37
|
| Thank you for the reply and the resource! |
 |
|
|
casizemore
Starting Member
1 Post |
Posted - 2011-01-03 : 14:47:05
|
| Trying to do something similar but return those zip codes within the paramaters as defined by this code. When I do this, I only ever get 1 return (The zip code entered by the user as their home zip). Do you see anything here that might cause this?<cfquery datasource="ProxisellZips" name="getlocs" > SELECT zipcode, latitude, longitude, ROUND((ACOS((SIN(#Session.HomeLat#/57.2958) * SIN(latitude/57.2958)) + (COS(#Session.HomeLat#/57.2958) * COS(latitude/57.2958) * COS(longitude/57.2958 - #Session.HomeLon#/57.2958)))) * 3963,2) AS distance FROM Zip_Codes WHERE (latitude >= #Session.HomeLat# - (#Session.PassedRadius#/111)) And (latitude <= #Session.HomeLat# + (#Session.PassedRadius#/111)) AND (longitude >= #Session.HomeLon# - (#Session.PassedRadius#/111)) AND (longitude <= #Session.HomeLon# + (#Session.PassedRadius#/111)) ORDER BY distance </cfquery>A Note that might be noteworthy is that the data is stored in MSSQL and the LAT LON are stored in "Float" fieldsData looks like this 40.922326 for lat and -72.637078 for lonSession.Passed Radius could be 5,10,20,50,100 Any helo would be greatly appreciated. I am pulling my hair out on this one. |
 |
|
|
Kristen
Test
22859 Posts |
Posted - 2011-01-04 : 04:18:53
|
| Your post will attract more viewers if you create a new thread, rather than post on this one that is 6 years old!Just Cut & Paste it to a new thread in a Forum for the version of SQL that you are using (the version may make a big difference, as there are Spatial functions in newer versions of SQL) |
 |
|
|
bhangra
Starting Member
4 Posts |
Posted - 2012-05-16 : 11:16:22
|
| If some can help with the 1 or 2 argument issue I would greatly appreciate it.SELECT decode(grouping(bg_detected_by),1,'Grand Total',bg_detected_by)Tester, CONCAT(Round(count(bg_target_rcyc) / count(bg_status)* 100), '%') Percentage_Compeleted,count(BG_Target_RCYC) Total_Target_Cycle,count(bg_status) Total_DefectsFrom Bugwhere BG_STATUS = 'Open'GROUP by Rollup(BG_DETECTED_BY,BG_STATUS)having (grouping(bg_detected_by) = grouping(bg_status)) |
 |
|
|
robvolk
Most Valuable Yak
15732 Posts |
Posted - 2012-05-16 : 11:36:52
|
| DECODE is not a SQL Server function, if you're using SQL Server 2012 you'd use the CHOOSE function.And please post a new thread rather than hijacking a year-old thread. |
 |
|
|
|
|
|
|
|