Adding a column to the result set that rounds off the cotangent. : COT « Function « SQL / MySQL






Adding a column to the result set that rounds off the cotangent.

      
mysql>
mysql> CREATE TABLE Test
    -> (
    ->     TestID SMALLINT NOT NULL PRIMARY KEY,
    ->     Amount SMALLINT NOT NULL
    -> );
Query OK, 0 rows affected (0.01 sec)

mysql> INSERT INTO Test VALUES
    -> (101, 12),
    -> (102, 1),
    -> (103, 139),
    -> (104, -37),
    -> (105, 0),
    -> (106, -16);
Query OK, 6 rows affected (0.00 sec)
Records: 6  Duplicates: 0  Warnings: 0

mysql>
mysql>
mysql> SELECT TestID, Amount, COT(Amount) AS Cotangent, ROUND(COT(Amount)) AS Rounded
    -> FROM Test
    -> ORDER BY TestID;
+--------+--------+-------------------+---------+
| TestID | Amount | Cotangent         | Rounded |
+--------+--------+-------------------+---------+
|    101 |     12 | -1.57267340639769 |      -2 |
|    102 |      1 | 0.642092615934331 |       1 |
|    103 |    139 |  1.03143886630872 |       1 |
|    104 |    -37 |  1.18938414411059 |       1 |
|    105 |      0 |              NULL |    NULL |
|    106 |    -16 | -3.32632319563545 |      -3 |
+--------+--------+-------------------+---------+
6 rows in set (0.00 sec)

mysql>
mysql> drop table test;
Query OK, 0 rows affected (0.00 sec)

   
    
    
    
    
    
  








Related examples in the same category