-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathArithmetic Operators in SQl.txt
More file actions
53 lines (50 loc) · 2.59 KB
/
Arithmetic Operators in SQl.txt
File metadata and controls
53 lines (50 loc) · 2.59 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
// Arithmetic Operators
syntax: SELECT column_name,column_name Operators VALUES from table_name;
Add operator ex
ex:SELECT s_id,name,address,dob,fees+100 from student_reg;
+------+---------+---------+------------+-----------+
| s_id | name | address | dob | fees+100 |
+------+---------+---------+------------+-----------+
| 101 | RAM | KTM | 1998-12-15 | 1100.23 |
| 102 | SITA | KTM | 2001-10-11 | 200100.12 |
| 103 | HARI | PKR | 2001-01-12 | 10100.52 |
| 104 | BIMAl | KTM | NULL | 1101.23 |
| 105 | KAMAL | PKR | 1956-12-12 | 100100.12 |
| 106 | SITA KC | PKR | 1998-02-02 | 20100.12 |
+------+---------+---------+------------+-----------+
sub operator ex:
ex: SELECT s_id,name,address,dob,fees-100 from student_reg;
+------+---------+---------+------------+-----------+
| s_id | name | address | dob | fees-100 |
+------+---------+---------+------------+-----------+
| 101 | RAM | KTM | 1998-12-15 | 900.23 |
| 102 | SITA | KTM | 2001-10-11 | 199900.12 |
| 103 | HARI | PKR | 2001-01-12 | 9900.52 |
| 104 | BIMAl | KTM | NULL | 901.23 |
| 105 | KAMAL | PKR | 1956-12-12 | 99900.12 |
| 106 | SITA KC | PKR | 1998-02-02 | 19900.12 |
+------+---------+---------+------------+-----------+
// div ex:
ex: SELECT s_id,name,address,dob,fees/100 from student_reg;
+------+---------+---------+------------+-------------+
| s_id | name | address | dob | fees/100 |
+------+---------+---------+------------+-------------+
| 101 | RAM | KTM | 1998-12-15 | 10.002300 |
| 102 | SITA | KTM | 2001-10-11 | 2000.001200 |
| 103 | HARI | PKR | 2001-01-12 | 100.005200 |
| 104 | BIMAl | KTM | NULL | 10.012300 |
| 105 | KAMAL | PKR | 1956-12-12 | 1000.001200 |
| 106 | SITA KC | PKR | 1998-02-02 | 200.001200 |
+------+---------+---------+------------+-------------+
// mul operator
ex:SELECT s_id,name,address,dob,fees*100 from student_reg;
+------+---------+---------+------------+-------------+
| s_id | name | address | dob | fees*100 |
+------+---------+---------+------------+-------------+
| 101 | RAM | KTM | 1998-12-15 | 100023.00 |
| 102 | SITA | KTM | 2001-10-11 | 20000012.00 |
| 103 | HARI | PKR | 2001-01-12 | 1000052.00 |
| 104 | BIMAl | KTM | NULL | 100123.00 |
| 105 | KAMAL | PKR | 1956-12-12 | 10000012.00 |
| 106 | SITA KC | PKR | 1998-02-02 | 2000012.00 |
+------+---------+---------+------------+-------------+