Difference between revisions of "COS"

From SQLZOO
Jump to: navigation, search
Line 26: Line 26:
 
INSERT INTO angle VALUES (3,1.0471);
 
INSERT INTO angle VALUES (3,1.0471);
 
</source>
 
</source>
In this example you return the cosine of each of the angles.  
+
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, angle, COS(angle)
 
SELECT id, angle, COS(angle)

Revision as of 14:42, 16 July 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