Difference between revisions of "SIN"

From SQLZOO
Jump to: navigation, search
 
(2 intermediate revisions by one user not shown)
Line 15: Line 15:
 
   SIN(3.14159/6) -> 0.5   
 
   SIN(3.14159/6) -> 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(
  func VARCHAR(10),
+
   id INTEGER,
  angle INTEGER
+
  angle FLOAT);
   id INTEGER
+
INSERT INTO angle VALUES (0,1);
INSERT INTO angle VALUES (COS,0,1);
+
INSERT INTO angle VALUES (1,0.7853);
INSERT INTO angle VALUES (COS,45,1.732051/2);
+
INSERT INTO angle VALUES (2,0.5235);
INSERT INTO angle VALUES (COS,45,1/1.41421);
+
INSERT INTO angle VALUES (3,1.0471);
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);
+
 
</source>
 
</source>
 
<div class='qu'>
 
 
In this example you return the sine of each of the angles.     
 
In this example you return the sine of each of the angles.     
 
<source lang='sql' class='def'>
 
<source lang='sql' class='def'>
SELECT id
+
SELECT id, angle, SIN(angle)
FROM angle
+
FROM angle
WHERE func = 'SIN'
+
 
</source>
 
</source>
 
</div>
 
</div>
Line 50: Line 36:
 
<ul>
 
<ul>
 
   <li>[[COS |COS function]]</li>
 
   <li>[[COS |COS function]]</li>
   <li>[[TAN function]]</li>
+
   <li>[[TAN |TAN function]]</li>
  <li>[[ATAN function]]</li>
+
 
</ul>
 
</ul>

Latest revision as of 09:56, 16 July 2012

Compatibility
SIN(s1 IN s2)
EngineOKAlternative
ingresYes
mysqlYes
oracleYes
postgresYes
sqlserverYes

SIN

SIN(f) returns the sine of f where f is in radians.

  SIN(3.14159/6) -> 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 sine of each of the angles.

SELECT id, angle, SIN(angle)
FROM angle

See also

Personal tools
Namespaces

Variants
Actions
Reference
Toolbox
Google AdSense