0% found this document useful (0 votes)
29 views6 pages

NUMERIC

The document contains SQL queries executed on a MySQL database. It selects data from a table called SCHOOL1, calculates mathematical functions like MOD, POW, ROUND, TRUNCATE on values, and explores the behavior of these functions by passing different parameters. The queries help understand various numeric functions in MySQL.

Uploaded by

nihalparteti26
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
29 views6 pages

NUMERIC

The document contains SQL queries executed on a MySQL database. It selects data from a table called SCHOOL1, calculates mathematical functions like MOD, POW, ROUND, TRUNCATE on values, and explores the behavior of these functions by passing different parameters. The queries help understand various numeric functions in MySQL.

Uploaded by

nihalparteti26
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 6

mysql> SELECT * FROM SCHOOL1;

+-------+-------+-------+---------+------------+
| SR_NO | NAME | CLASS | SECTION | DOB |
+-------+-------+-------+---------+------------+
| 1 | NIHAL | 12 | A | 2006-04-26 |
| 2 | HARI | 12 | A | 2005-12-01 |
| 3 | SHIV | 12 | A | 2006-05-20 |
| 4 | RAM | 12 | A | 2006-08-05 |
| 5 | OM | 12 | A | 2007-10-11 |
+-------+-------+-------+---------+------------+
5 rows in set (0.02 sec)
mysql> SELECT MOD(25,2);
+-----------+
| MOD(25,2) |
+-----------+
| 1 |
+-----------+
1 row in set (0.00 sec)

mysql> SELECT MOD(25,5);


+-----------+
| MOD(25,5) |
+-----------+
| 0 |
+-----------+
1 row in set (0.00 sec)

mysql> SELECT POW(3,5);


+----------+
| POW(3,5) |
+----------+
| 243 |
+----------+
1 row in set (0.00 sec)

mysql> SELECT POWER(15,2);


+-------------+
| POWER(15,2) |
+-------------+
| 225 |
+-------------+
1 row in set (0.00 sec)

mysql> SELECT SIGN(-5);


+----------+
| SIGN(-5) |
+----------+
| -1 |
+----------+
1 row in set (0.00 sec)

mysql> SELECT SIGN(12);


+----------+
| SIGN(12) |
+----------+
| 1 |
+----------+
1 row in set (0.00 sec)
mysql> SELECT SIGN(0);
+---------+
| SIGN(0) |
+---------+
| 0 |
+---------+
1 row in set (0.00 sec)

mysql> SELECT SQRT(81);


+----------+
| SQRT(81) |
+----------+
| 9 |
+----------+
1 row in set (0.00 sec)

mysql> SELECT SIGN(NULL);


+------------+
| SIGN(NULL) |
+------------+
| NULL |
+------------+
1 row in set (0.00 sec)
mysql> SELECT POW(SR_NO,3) FROM SCHOOL1;
+--------------+
| POW(SR_NO,3) |
+--------------+
| 1 |
| 8 |
| 27 |
| 64 |
| 125 |
+--------------+
5 rows in set (0.00 sec)

mysql> SELECT SR_NO,POW(SR_NO,3) AS 'SR_NO RISE 2' FROM SCHOOL1;


+-------+--------------+
| SR_NO | SR_NO RISE 2 |
+-------+--------------+
| 1 | 1 |
| 2 | 8 |
| 3 | 27 |
| 4 | 64 |
| 5 | 125 |
+-------+--------------+
5 rows in set (0.00 sec)

mysql> SELECT SR_NO,POW(SR_NO,3) AS 'SR_NO RISE 3' FROM SCHOOL1;


+-------+--------------+
| SR_NO | SR_NO RISE 3 |
+-------+--------------+
| 1 | 1 |
| 2 | 8 |
| 3 | 27 |
| 4 | 64 |
| 5 | 125 |
+-------+--------------+
5 rows in set (0.00 sec)
mysql> SELECT * FROM SCHOOL1;
+-------+-------+-------+---------+------------+
| SR_NO | NAME | CLASS | SECTION | DOB |
+-------+-------+-------+---------+------------+
| 1 | NIHAL | 12 | A | 2006-04-26 |
| 2 | HARI | 12 | A | 2005-12-01 |
| 3 | SHIV | 12 | A | 2006-05-20 |
| 4 | RAM | 12 | A | 2006-08-05 |
| 5 | OM | 12 | A | 2007-10-11 |
+-------+-------+-------+---------+------------+
5 rows in set (0.00 sec)

mysql> SELECT ROUND(15.532,0);


+-----------------+
| ROUND(15.532,0) |
+-----------------+
| 16 |
+-----------------+
1 row in set (0.00 sec)

mysql> SELECT ROUND(15.532,1);


+-----------------+
| ROUND(15.532,1) |
+-----------------+
| 15.5 |
+-----------------+
1 row in set (0.00 sec)

mysql> SELECT ROUND(15.532,-1);


+------------------+
| ROUND(15.532,-1) |
+------------------+
| 20 |
+------------------+
1 row in set (0.00 sec)

mysql> SELECT ROUND(15.532,2);


+-----------------+
| ROUND(15.532,2) |
+-----------------+
| 15.53 |
+-----------------+
1 row in set (0.00 sec)

mysql> SELECT ROUND(15.551,2);


+-----------------+
| ROUND(15.551,2) |
+-----------------+
| 15.55 |
+-----------------+
1 row in set (0.00 sec)

mysql> SELECT ROUND(15.555,2);


+-----------------+
| ROUND(15.555,2) |
+-----------------+
| 15.56 |
+-----------------+
1 row in set (0.00 sec)

mysql> SELECT ROUND(14.55,-1);


+-----------------+
| ROUND(14.55,-1) |
+-----------------+
| 10 |
+-----------------+
1 row in set (0.00 sec)

mysql> SELECT ROUND(17.12,-2);


+-----------------+
| ROUND(17.12,-2) |
+-----------------+
| 0 |
+-----------------+
1 row in set (0.00 sec)

mysql> SELECT ROUND(15.499);


+---------------+
| ROUND(15.499) |
+---------------+
| 15 |
+---------------+
1 row in set (0.00 sec)

mysql> SELECT ROUND(99,-2);


+--------------+
| ROUND(99,-2) |
+--------------+
| 100 |
+--------------+
1 row in set (0.00 sec)

mysql> SELECT ROUND(501,-3);


+---------------+
| ROUND(501,-3) |
+---------------+
| 1000 |
+---------------+
1 row in set (0.00 sec)

mysql> SELECT ROUND(501,-2);


+---------------+
| ROUND(501,-2) |
+---------------+
| 500 |
+---------------+
1 row in set (0.00 sec)

mysql> SELECT ROUND(500,-2);


+---------------+
| ROUND(500,-2) |
+---------------+
| 500 |
+---------------+
1 row in set (0.00 sec)
mysql> SELECT TRUNCATE(15.1515,3);
+---------------------+
| TRUNCATE(15.1515,3) |
+---------------------+
| 15.151 |
+---------------------+
1 row in set (0.00 sec)

mysql> SELECT TRUNCATE(15.1515,5);


+---------------------+
| TRUNCATE(15.1515,5) |
+---------------------+
| 15.1515 |
+---------------------+
1 row in set (0.00 sec)

mysql> SELECT TRUNCATE(15.1515,1);


+---------------------+
| TRUNCATE(15.1515,1) |
+---------------------+
| 15.1 |
+---------------------+
1 row in set (0.00 sec)

mysql> SELECT TRUNCATE(15.1515,-1);


+----------------------+
| TRUNCATE(15.1515,-1) |
+----------------------+
| 10 |
+----------------------+
1 row in set (0.01 sec)

mysql> SELECT TRUNCATE(15.1515,-2);


+----------------------+
| TRUNCATE(15.1515,-2) |
+----------------------+
| 0 |
+----------------------+
1 row in set (0.00 sec)

mysql> SELECT TRUNCATE(15.1515,0);


+---------------------+
| TRUNCATE(15.1515,0) |
+---------------------+
| 15 |
+---------------------+
1 row in set (0.00 sec)

mysql> SELECT TRUNCATE(115.1515,-1);


+-----------------------+
| TRUNCATE(115.1515,-1) |
+-----------------------+
| 110 |
+-----------------------+
1 row in set (0.00 sec)

mysql> SELECT TRUNCATE(115.1515,-2);


+-----------------------+
| TRUNCATE(115.1515,-2) |
+-----------------------+
| 100 |
+-----------------------+
1 row in set (0.00 sec)

You might also like