Difference between revisions of "COS"

From SQLZOO
Jump to: navigation, search
(Created page with "<table align='right' border='1'> <caption>Compatibility</caption> <tr><th colspan='3'>COS(a)</th></tr> <tr><td align='center'>'''Engine'''</td><td align='center'>'''OK'''</td>...")
 
 
(14 intermediate revisions by 2 users not shown)
Line 13: Line 13:
 
<p></p>  
 
<p></p>  
 
<pre style='width:50ex'>
 
<pre style='width:50ex'>
   COS(3.14159/3) -> 0.5  
+
   COS(3.14159/3) -> -0.5  
 
</pre>
 
</pre>
 
+
<div class='ht'>
<div class='qu'>
+
<div class=params>schema:scott</div>
In this example you return the cosine of each of the angles.  
+
<source lang=sql class='tidy'> DROP TABLE angle</source>
 +
<source lang=sql class='setup'> CREATE TABLE angle(
 +
  id INTEGER,
 +
  angle FLOAT);
 +
INSERT INTO angle VALUES (0,1);
 +
INSERT INTO angle VALUES (1,0.7853);
 +
INSERT INTO angle VALUES (2,0.5235);
 +
INSERT INTO angle VALUES (3,1.0471);
 +
</source>
 +
In this example you return the cosine of each of the angles.
 +
<source lang='sql' class='def e-oracle'>
 +
SELECT id, angle, COS(angle)
 +
FROM scott.angle
 +
</source> 
 
<source lang='sql' class='def'>
 
<source lang='sql' class='def'>
SELECT id,
+
SELECT id, angle, COS(angle)
      COS(th)
+
FROM angle
  FROM angle
+
 
</source>
 
</source>
 
</div>
 
</div>
Line 27: Line 39:
 
<p>See also</p>
 
<p>See also</p>
 
<ul>
 
<ul>
   <li>[[SIN function]]</li>
+
   <li>[[SIN |SIN function]]</li>
   <li>[[TAN function]]</li>
+
   <li>[[TAN |TAN function]]</li>
  <li>[[ATAN function]]</li>
+
 
</ul>
 
</ul>
 +
 +
{{Languages}}

Latest revision as of 11:23, 1 October 2012

Compatibility
COS(a)
EngineOKAlternative
ingresYes
mysqlYes
oracleYes
postgresYes
sqlserverYes

COS

COS(f) returns the cosine of f where f is in radians.

  COS(3.14159/3) -> -0.5 
schema:scott
 DROP TABLE angle
 CREATE TABLE angle(
  id INTEGER,
  angle FLOAT);
INSERT INTO angle VALUES (0,1);
INSERT INTO angle VALUES (1,0.7853);
INSERT INTO angle VALUES (2,0.5235);
INSERT INTO angle VALUES (3,1.0471);

In this example you return the cosine of each of the angles.

SELECT id, angle, COS(angle)
FROM scott.angle
SELECT id, angle, COS(angle)
FROM angle

See also

Language: English  • Deutsch
Personal tools
Namespaces

Variants
Actions
Reference
Toolbox
Google AdSense