Difference between revisions of "COS"

From SQLZOO
Jump to: navigation, search
Line 16: Line 16:
 
</pre>
 
</pre>
  
 +
<div class=params>schema:scott</div>
 +
<source lang=sql class='tidy'> drop TABLE angle
 +
<source lang=sql class='setup'> create TABLE angle(
 +
  type VARCHAR(10),
 +
  angle INTEGER
 +
  id INTEGER
 +
INSERT INTO angle VALUES (COS,0,1);
 +
INSERT INTO angle VALUES (COS,45,1.732051/2);
 +
INSERT INTO angle VALUES (COS,45,1/1.41421);
 +
INSERT INTO angle VALUES (COS,60,1/2);
 +
INSERT INTO angle VALUES (COS,90,NULL);
 +
INSERT INTO angle VALUES (SIN,0,0);
 +
INSERT INTO angle VALUES (SIN,30,1/2);
 +
INSERT INTO angle VALUES (SIN,45,1/1.41421);
 +
INSERT INTO angle VALUES (SIN,60,1.732051/2);
 +
INSERT INTO angle VALUES (SIN,90,1);
 +
INSERT INTO angle VALUES (TAN,0,0);
 +
INSERT INTO angle VALUES (TAN,30,1/1.732051);
 +
INSERT INTO angle VALUES (TAN,45,1);
 +
INSERT INTO angle VALUES (TAN,60,1.732051);
 +
INSERT INTO angle VALUES (TAN,90,1/0);
 
<div class='qu'>
 
<div class='qu'>
 
In this example you return the cosine of each of the angles.   
 
In this example you return the cosine of each of the angles.   

Revision as of 09:14, 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
<SOURCE lang=SQL class='setup'> CREATE TABLE angle(
  TYPE VARCHAR(10),
  angle INTEGER
  id INTEGER
INSERT INTO angle VALUES (COS,0,1);
INSERT INTO angle VALUES (COS,45,1.732051/2);
INSERT INTO angle VALUES (COS,45,1/1.41421);
INSERT INTO angle VALUES (COS,60,1/2);
INSERT INTO angle VALUES (COS,90,NULL);
INSERT INTO angle VALUES (SIN,0,0);
INSERT INTO angle VALUES (SIN,30,1/2);
INSERT INTO angle VALUES (SIN,45,1/1.41421);
INSERT INTO angle VALUES (SIN,60,1.732051/2);
INSERT INTO angle VALUES (SIN,90,1);
INSERT INTO angle VALUES (TAN,0,0);
INSERT INTO angle VALUES (TAN,30,1/1.732051);
INSERT INTO angle VALUES (TAN,45,1);
INSERT INTO angle VALUES (TAN,60,1.732051);
INSERT INTO angle VALUES (TAN,90,1/0);
<div class='qu'>
IN this example you RETURN the cosine OF each OF the angles.   
<SOURCE lang='sql' class='def'>
SELECT id,
       COS(th)
  FROM angle

</div>

See also

Personal tools
Namespaces

Variants
Actions
Reference
Toolbox
Google AdSense