Difference between revisions of "COS"
From SQLZOO
| Line 15: | Line 15: | ||
COS(3.14159/3) -> 0.5 | COS(3.14159/3) -> 0.5 | ||
</pre> | </pre> | ||
| − | + | <div class='ht'> | |
<div class=params>schema:scott</div> | <div class=params>schema:scott</div> | ||
<source lang=sql class='tidy'> DROP TABLE angle</source> | <source lang=sql class='tidy'> DROP TABLE angle</source> | ||
<source lang=sql class='setup'> CREATE TABLE angle( | <source lang=sql class='setup'> CREATE TABLE angle( | ||
| − | + | id INTEGER, | |
| − | + | angle FLOAT); | |
| − | id INTEGER | + | INSERT INTO angle VALUES (0,1); |
| − | + | INSERT INTO angle VALUES (1,0.7853); | |
| − | + | INSERT INTO angle VALUES (2,0.5235); | |
| − | INSERT INTO angle VALUES ( | + | |
| − | INSERT INTO angle VALUES ( | + | |
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | INSERT INTO angle VALUES ( | + | |
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
</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'> | <source lang='sql' class='def'> | ||
Revision as of 09:48, 16 July 2012
| COS(a) | ||
|---|---|---|
| Engine | OK | Alternative |
| ingres | Yes | |
| mysql | Yes | |
| oracle | Yes | |
| postgres | Yes | |
| sqlserver | Yes | |
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);
In this example you return the cosine of each of the angles.
SELECT id FROM angle WHERE func = 'COS'
See also