Sie sind auf Seite 1von 6

Q12.

Create table SHOES and answer the questions that follow :


mysql> create table shoes
-> (Code int primary key,
-> Name varchar(30),
-> Type varchar(20),
-> size int,
-> Cost double,
-> Margun double,
-> Qty int);
Query OK, 0 rows affected (0.80 sec)

mysql> Insert into shoes


-> values(1001,'School Canvas','School',6,132.50,2.00,1200);
Query OK, 1 row affected (0.09 sec)

mysql> Insert into shoes


-> values(1002,'School Canvas','School',7,135.50,2.00,800);
Query OK, 1 row affected (0.10 sec)

mysql> Insert into shoes


-> values(1003,'School Canvas','School',7,140.75,2.00,600);
Query OK, 1 row affected (0.08 sec)
mysql> Insert into shoes
-> values(1011,'School Leather','School',6,232.50,2.00,2200);
Query OK, 1 row affected (0.16 sec)

mysql> Insert into shoes


-> values(1012,'School Leather','School',7,270.00,2.00,1280);
Query OK, 1 row affected (0.10 sec)

mysql> Insert into shoes


-> values(1013,'School Leather','School',8,320.75,Null,1100);
Query OK, 1 row affected (0.10 sec)

mysql> Insert into shoes


-> values(1101,'Galaxy','Office',7,640.00,3.00,200);
Query OK, 1 row affected (0.07 sec)

mysql> Insert into shoes


-> values(1102,'Galaxy','Office',8,712.00,3.00,500);
Query OK, 1 row affected (0.10 sec)

mysql> Insert into shoes


-> values(1103,'Galaxy','Office',9,720.00,3.00,400);
Query OK, 1 row affected (0.09 sec)

mysql> Insert into shoes


-> values(1201,'Tracker','Sports',6,700.00,Null,280);
Query OK, 1 row affected (0.10 sec)

mysql> Insert into shoes


-> values(1202,'Tracker','Sports',7,745.25,3.50,Null);
Query OK, 1 row affected (0.08 sec)

mysql> Insert into shoes


-> values(1203,'Tracker','Sports',8,800.50,3.50,600);
Query OK, 1 row affected (0.07 sec)

mysql> Insert into shoes


-> values(1204,'Tracker','Sports',9,843.00,Null,860);
Query OK, 1 row affected (0.09 sec)
1) Find the highest cost of any shoe of type School.
mysql> select max(cost) "Highest cost"
-> from shoes
-> where type='School';

2) To find the Highest Selling Price of any type of shoe.


mysql> Select max(cost) "Highest Cost"
-> from shoes;
3) To find the lowest cost of any shoe of type School.
mysql> Select min(cost) "Lowest cost"
-> from shoes
-> where type="School";

5) To find the average quantity in stock for the shoes of type Sports.
mysql> Select avg(Qty) "Average Quantity"
-> from shoes
-> where type="Sports";

6) To find the total quantity(Cost x Quantity) of shoes of type Office present


in the inventory.
mysql> Select qty*cost as Value
-> from shoes
-> where type="Office";
7) To count the different types of shoes that the factory produces
mysql> Select Type, count(*) as Total from shoes
-> group by type;

8) To count the number of orders of qtty more than 300.


mysql> Select Type, Name, Qty
-> from shoes, orders
-> where Code=Shoes_code and qtty>300;

9) Find the total qty of shoes of various types.


mysql> Select type,sum(Qty) "Total Qty"
-> from shoes
-> group by type;
10) To find the max, min and avg margin of each type of shoes.
mysql> Select type,max(Margun) "Max Margin",min(Margun) "Min
Margin",avg(Margun) "Avg Margin"
-> from shoes
-> group by type;

Das könnte Ihnen auch gefallen