Practical 1 Chinmayi

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

Consider the tables given below and answer the

following questions.

I)TABLE:SCHOOLBUS
RNO AREA CAP NO DIST TRAVEL CHARGES
1 VASANT KUNJ 100 120 10 SHIVAM TRAVELS 100000
2 HAUZ KHAS 80 80 10 ANAND TRAVELS 85000
3 PITUMPURA 60 55 30 ANAND TRAVELS 60000
4 ROHINI 100 90 35 ANAND TRAVELS 100000
5 YAMUNA VIHAR 50 60 20 BHALLA CO. 55000
6 KRISHNA VIHAR 70 80 30 YADAV CO. 80000
7 VASUNDHRA 100 110 20 YADAV CO. 100000
8 PASCHIM VIHAR 40 40 20 SPEED TRAVELS 55000
9 SAKET 120 120 10 SPEED TRAVELS 100000
10 JANAKPURI 100 100 20 KISAN TOURS 95000

Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 3
Server version: 5.5.15 MySQL Community Server (GPL)

Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights
reserved.

Oracle is a registered trademark of Oracle Corporation and/or its


affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input
statement.

mysql> USE CHINMAYI;


Database changed
mysql> CREATE TABLE SCHOOLBUS(RNO INT(1) PRIMARY KEY, AREA
VARCHAR(20), CAP INT(3), NO INT(3), DIST INT(2), TRAVEL VARCHAR(20),
CHARGE INT(10));
Query OK, 0 rows affected (0.35 sec)
mysql> INSERT INTO SCHOOLBUS VALUES(1, "VASANT KUNJ", 100, 120, 10,
"SHIVAM TRAVELS", 100000);
Query OK, 1 row affected (0.12 sec)

mysql> INSERT INTO SCHOOLBUS VALUES(2, "HAUZ KHAS", 80, 80, 10,
"ANAND TRAVELS", 85000);
Query OK, 1 row affected (0.07 sec)

mysql> INSERT INTO SCHOOLBUS VALUES(3, "PITUMPURA", 60, 55, 30,


"ANAND TRAVELS", 60000);
Query OK, 1 row affected (0.08 sec)

mysql> INSERT INTO SCHOOLBUS VALUES(4, "ROHINI", 100, 90, 35, "ANAND
TRAVELS", 100000);
Query OK, 1 row affected (0.08 sec)

mysql> INSERT INTO SCHOOLBUS VALUES(5, "YAMUNA VIHAR", 50, 60, 20,
"BHALA CO.", 55000);
Query OK, 1 row affected (0.08 sec)

mysql> INSERT INTO SCHOOLBUS VALUES(6, "KRISHNA VIHAR", 70, 80, 30,
"YADAV CO.", 80000);
Query OK, 1 row affected (0.09 sec)

mysql> INSERT INTO SCHOOLBUS VALUES(7, "VASUNDHARA", 100, 110, 20,


"YADAV CO.", 100000);
Query OK, 1 row affected (0.08 sec)

mysql> INSERT INTO SCHOOLBUS VALUES(8, "PASCHIM VIHAR", 40, 40, 20,
"SPEED TRAVELS", 55000);
Query OK, 1 row affected (0.04 sec)

mysql> INSERT INTO SCHOOLBUS VALUES(9, "SAKET", 120, 120, 10, "SPEED
TRAVELS", 100000);
Query OK, 1 row affected (0.10 sec)
mysql> INSERT INTO SCHOOLBUS VALUES(10, "JANAKPURI", 100, 100, 20,
"KISAN TOURS", 95000);
Query OK, 1 row affected (0.08 sec)

mysql> SELECT * FROM SCHOOLBUS;


+-----+---------------+------+------+------+----------------+--------+

| RNO | AREA | CAP | NO | DIST | TRAVEL | CHARGE |

+-----+---------------+------+------+------+----------------+--------+

| 1 | VASANT KUNJ | 100 | 120 | 10 | SHIVAM TRAVELS | 100000 |

| 2 | HAUZ KHAS | 80 | 80 | 10 | ANAND TRAVELS | 85000 |

| 3 | PITUMPURA | 60 | 55 | 30 | ANAND TRAVELS | 60000 |

| 4 | ROHINI | 100 | 90 | 35 | ANAND TRAVELS | 100000 |

| 5 | YAMUNA VIHAR | 50 | 60 | 20 | BHALLA CO. | 55000 |

| 6 | KRISHNA VIHAR | 70 | 80 | 30 | YADAV CO. | 80000 |

| 7 | VASUNDHARA | 100 | 110 | 20 | YADAV CO. | 100000 |

| 8 | PASCHIM VIHAR | 40 | 40 | 20 | SPEED TRAVELS | 55000 |

| 9 | SAKET | 120 | 120 | 10 | SPEED TRAVELS | 100000 |

| 10 | JANAKPURI | 100 | 100 | 20 | KISAN TOURS | 95000 |

+-----+---------------+------+------+------+----------------+--------+

10 rows in set (0.00 sec)

1. Show information of students when capacity is more than 80 in


order of route number.

mysql> SELECT * FROM SCHOOLBUS WHERE CAP>80 ORDER BY RNO;


+-----+-------------+------+------+------+----------------+--------+
| RNO | AREA | CAP | NO | DIST | TRAVEL | CHARGE |
+-----+-------------+------+------+------+----------------+--------+
| 1 | VASANT KUNJ | 100 | 120 | 10 | SHIVAM TRAVELS | 100000 |
| 4 | ROHINI | 100 | 90 | 35 | ANAND TRAVELS | 100000 |
| 7 | VASUNDHARA | 100 | 110 | 20 | YADAV CO. | 100000 |
| 9 | SAKET | 120 | 120 | 10 | SPEED TRAVELS | 100000 |
| 10 | JANAKPURI | 100 | 100 | 20 | KISAN TOURS | 95000 |
+-----+-------------+------+------+------+----------------+--------+
5 rows in set (0.00 sec)
2. Show area covered for buses more than 20 km and charges less than
80000.
mysql> SELECT AREA FROM SCHOOLBUS WHERE DIST>20 AND CHARGE<80000;
+-----------+
| AREA |
+-----------+
| PITUMPURA |
+-----------+
1 row in set (0.00 sec)

3. Show names of all transporters and their charges.


mysql> SELECT TRAVEL, CHARGE FROM SCHOOLBUS;
+----------------+--------+
| TRAVEL | CHARGE |
+----------------+--------+
| SHIVAM TRAVELS | 100000 |
| ANAND TRAVELS | 85000 |
| ANAND TRAVELS | 60000 |
| ANAND TRAVELS | 100000 |
| BHALLA CO. | 55000 |
| YADAV CO. | 80000 |
| YADAV CO. | 100000 |
| SPEED TRAVELS | 55000 |
| SPEED TRAVELS | 100000 |
| KISAN TOURS | 95000 |
+----------------+--------+
10 rows in set (0.00 sec)

4. Display name of transporters where bus is covering distance more


than 10 km but less than 30 km.
mysql> SELECT TRAVEL FROM SCHOOLBUS WHERE DIST>10 AND DIST<30;
+---------------+
| TRAVEL |
+---------------+
| BHALA CO. |
| YADAV CO. |
| SPEED TRAVELS |
| KISAN TOURS |
+---------------+
4 rows in set (0.00 sec)

5. Display charges of transporters who are charging above 20000 but


less than 80000.
mysql> SELECT TRAVEL FROM SCHOOLBUS WHERE CHARGE>20000 AND
CHARGE<80000;
+---------------+
| TRAVEL |
+---------------+
| ANAND TRAVELS |
| BHALLA CO. |
| SPEED TRAVELS |
+---------------+
3 rows in set (0.00 sec)

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy