Q 5

You might also like

Download as txt, pdf, or txt
Download as txt, pdf, or txt
You are on page 1of 2

mysql> create database compsci;

Query OK, 1 row affected (0.18 sec)

mysql> use compsci;


Database changed
mysql> create table MOV(
-> No int primary key,
-> Title varchar(255),
-> Type varchar(255),
-> Rating varchar(255),
-> Stars int,
-> Qty int,
-> Price int
-> );
Query OK, 0 rows affected (1.31 sec)

mysql>
mysql>
mysql>
mysql>
mysql>
mysql> insert into MOV(no,title,type,rating,stars,qty,price)
-> values(10,"abc","xyz","14+",5,15,15),
-> (1,"abc","xyz","14+",5,15,15),
-> (2,"xbc","ayz","16+",4.5,10,25),
-> (3,"zbc","cyz","15+",3,19,35),
-> (4,"rbc","eyz","11+",4.5,25,20),
-> (5,"jbc","dyz","14+",5,15,10);
Query OK, 6 rows affected (0.14 sec)
Records: 6 Duplicates: 0 Warnings: 0

mysql> select * from mov;


+----+-------+------+--------+-------+------+-------+
| No | Title | Type | Rating | Stars | Qty | Price |
+----+-------+------+--------+-------+------+-------+
| 1 | abc | xyz | 14+ | 5 | 15 | 15 |
| 2 | xbc | ayz | 16+ | 5 | 10 | 25 |
| 3 | zbc | cyz | 15+ | 3 | 19 | 35 |
| 4 | rbc | eyz | 11+ | 5 | 25 | 20 |
| 5 | jbc | dyz | 14+ | 5 | 15 | 10 |
| 10 | abc | xyz | 14+ | 5 | 15 | 15 |
+----+-------+------+--------+-------+------+-------+
6 rows in set (0.00 sec)

mysql> select * from mov where price>20 order by price;


+----+-------+------+--------+-------+------+-------+
| No | Title | Type | Rating | Stars | Qty | Price |
+----+-------+------+--------+-------+------+-------+
| 2 | xbc | ayz | 16+ | 5 | 10 | 25 |
| 3 | zbc | cyz | 15+ | 3 | 19 | 35 |
+----+-------+------+--------+-------+------+-------+
2 rows in set (0.00 sec)

mysql> select * from mov order by qty desc;


+----+-------+------+--------+-------+------+-------+
| No | Title | Type | Rating | Stars | Qty | Price |
+----+-------+------+--------+-------+------+-------+
| 4 | rbc | eyz | 11+ | 5 | 25 | 20 |
| 3 | zbc | cyz | 15+ | 3 | 19 | 35 |
| 1 | abc | xyz | 14+ | 5 | 15 | 15 |
| 5 | jbc | dyz | 14+ | 5 | 15 | 10 |
| 10 | abc | xyz | 14+ | 5 | 15 | 15 |
| 2 | xbc | ayz | 16+ | 5 | 10 | 25 |
+----+-------+------+--------+-------+------+-------+
6 rows in set (0.00 sec)

mysql> select no,qty*price as current_value,qty*price*0.5 as replacement_value from


mov;
+----+---------------+-------------------+
| no | current_value | replacement_value |
+----+---------------+-------------------+
| 1 | 225 | 112.5 |
| 2 | 250 | 125.0 |
| 3 | 665 | 332.5 |
| 4 | 500 | 250.0 |
| 5 | 150 | 75.0 |
| 10 | 225 | 112.5 |
+----+---------------+-------------------+
6 rows in set (0.00 sec)

You might also like