SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 SQL Help - Round requires 2 or 3 arguments
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

jrockfl
Posting Yak Master

223 Posts

Posted - 08/10/2005 :  11:30:11  Show Profile  Visit jrockfl's Homepage  Reply with Quote
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 distance
FROM ZipCodes

Seventhnight
Flowing Fount of Yak Knowledge

USA
2878 Posts

Posted - 08/10/2005 :  11:34:13  Show Profile  Visit Seventhnight's Homepage  Reply with Quote
quote:
From BOL
Syntax
ROUND ( numeric_expression , length [ , function ] )

Arguments
numeric_expression

Is an expression of the exact numeric or approximate numeric data type category, except for the bit data type.

length

Is 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.

function

Is 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 distance
FROM 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."
Go to Top of Page

jrockfl
Posting Yak Master

223 Posts

Posted - 08/10/2005 :  11:40:37  Show Profile  Visit jrockfl's Homepage  Reply with Quote
Thank you for the reply and the resource!
Go to Top of Page

casizemore
Starting Member

1 Posts

Posted - 01/03/2011 :  14:47:05  Show Profile  Reply with Quote
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" fields

Data looks like this 40.922326 for lat and -72.637078 for lon
Session.Passed Radius could be 5,10,20,50,100 Any helo would be greatly appreciated. I am pulling my hair out on this one.
Go to Top of Page

Kristen
Test

United Kingdom
22191 Posts

Posted - 01/04/2011 :  04:18:53  Show Profile  Reply with Quote
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)
Go to Top of Page

bhangra
Starting Member

4 Posts

Posted - 05/16/2012 :  11:16:22  Show Profile  Reply with Quote
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_Defects
From Bug
where BG_STATUS = 'Open'
GROUP by Rollup(BG_DETECTED_BY,BG_STATUS)
having (grouping(bg_detected_by) = grouping(bg_status))
Go to Top of Page

robvolk
Most Valuable Yak

USA
15558 Posts

Posted - 05/16/2012 :  11:36:52  Show Profile  Visit robvolk's Homepage  Reply with Quote
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.
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.06 seconds. Powered By: Snitz Forums 2000