Documente Academic
Documente Profesional
Documente Cultură
PUJITH K L
PROGRAM 05
DLOCATION(DNo,DLoc)
1. Make a list of all project numbers for projects that involve an employee
2. Show the resulting salaries if every employee working on the ‘IoT’ project is
3. Find the sum of the salaries of all employees of the ‘Accounts’ department, as
well as the maximum salary, the minimum salary, and the average salary in
this department
4. Retrieve the name of each employee who works on all the projects
5. For each department that has more than five employees, retrieve the
department number and the number of its employees who are making more
Enter password:
Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved.
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
+--------------------+
| Database |
+--------------------+
| information_schema |
| COLLEGE1 |
| MOVIE |
| college |
| hospital |
| library |
| mysql |
| performance_schema |
| school |
+--------------------+
+--------------------+
| Database |
+--------------------+
| information_schema |
| COLLEGE1 |
| COMPANY |
| MOVIE |
| college |
| hospital |
| library |
| mysql |
| performance_schema |
| school |
+--------------------+
You can turn off this feature to get a quicker startup with -A
mysql> CREATE TABLE EMPLOYEE(SSN VARCHAR(20) PRIMARY KEY, FNAME VARCHAR(20), LNAME
VARCHAR(20), ADDRESS VARCHAR(20),SEX CHAR(1),SALARY INTEGER(10),SUPERSSN
VARCHAR(20),DNO VARCHAR(20),FOREIGN KEY (SUPERSSN) REFERENCES EMPLOYEE(SSN),FOREIGN
KEY (DNO) REFERENCES DEPARTMENT(DNO));
Query OK, 0 rows affected (0.11 sec)
+--------------+-------------+------+-----+---------+-------+
+--------------+-------------+------+-----+---------+-------+
+--------------+-------------+------+-----+---------+-------+
+----------+-------------+------+-----+---------+-------+
+----------+-------------+------+-----+---------+-------+
+----------+-------------+------+-----+---------+-------+
+-------+-------------+------+-----+---------+-------+
+-------+-------------+------+-----+---------+-------+
+-------+-------------+------+-----+---------+-------+
+-----------+-------------+------+-----+---------+-------+
+-----------+-------------+------+-----+---------+-------+
+-----------+-------------+------+-----+---------+-------+
+-------+-------------+------+-----+---------+-------+
+-------+-------------+------+-----+---------+-------+
+-------+-------------+------+-----+---------+-------+
+----------+-------------+------+-----+---------+-------+
+----------+-------------+------+-----+---------+-------+
+--------------+-------------+------+-----+---------+-------+
+--------------+-------------+------+-----+---------+-------+
+--------------+-------------+------+-----+---------+-------+
+-------+-------------+------+-----+---------+-------+
+-------+-------------+------+-----+---------+-------+
+-------+-------------+------+-----+---------+-------+
+-----------+-------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+-----------+-------------+------+-----+---------+-------+
+-----------+-------------+------+-----+---------+-------+
+-------+-------------+------+-----+---------+-------+
+-------+-------------+------+-----+---------+-------+
+-------+-------------+------+-----+---------+-------+
+---------+---------+----------+------+-------+-----------+------+--------+
+---------+---------+----------+------+-------+-----------+------+--------+
+---------+---------+----------+------+-------+-----------+------+--------+
+-----+----------+--------------+---------+
+-----+----------+--------------+---------+
| 2 | IT | 2001-08-16 | YGIT01 |
+-----+----------+--------------+---------+
+-----------+-----+
| DLOC | DNO |
+-----------+-----+
| BANGALORE | 1 |
| BANGALORE | 2 |
| BANGALORE | 3 |
| MANGALORE | 4 |
| MANGALORE | 5 |
+-----------+-----+
5 rows in set (0.00 sec)
+-----+-------------------+------+-----------+
+-----+-------------------+------+-----------+
+-----+-------------------+------+-----------+
+-------+---------+-----+
+-------+---------+-----+
| 5 | YGACC01 | 104 |
| 6 | YGACC02 | 105 |
| 4 | YGCSE01 | 100 |
| 6 | YGCSE01 | 101 |
| 8 | YGCSE01 | 102 |
| 10 | YGCSE02 | 100 |
| 6 | YGCSE03 | 102 |
| 3 | YGCSE04 | 100 |
| 4 | YGCSE05 | 101 |
| 5 | YGCSE06 | 102 |
| 7 | YGECE01 | 103 |
| 4 | YGISE01 | 106 |
| 10 | YGIT01 | 107 |
+-------+---------+-----+
1. Make a list of all project numbers for projects that involve an employee
+-----+
| PNO |
+-----+
| 100 |
| 101 |
| 102 |
| 103 |
| 104 |
| 105 |
| 106 |
| 107 |
+-----+
2. Show the resulting salaries if every employee working on the ‘IoT’ project is
+-------+-------+----------+
+-------+-------+----------+
+-------+-------+----------+
3. Find the sum of the salaries of all employees of the ‘Accounts’ department, as
well as the maximum salary, the minimum salary, and the average salary in
this department
+---------------+---------------+---------------+---------------+
+---------------+---------------+---------------+---------------+
+---------------+---------------+---------------+---------------+
+-------+-------+
| FNAME | LNAME |
+-------+-------+
| JAMES | SMITH |
+-------+-------+
5. For each department that has more than five employees, retrieve the
department number and the number of its employees who are making more
+-----+----------+
| DNO | COUNT(*) |
+-----+----------+
|5 | 3|
+-----+----------+