0% found this document useful (0 votes)
3 views5 pages

SQL Queries From Images

The document contains SQL queries related to employee management, project details, and book inventory. It includes commands for selecting, updating, and inserting data across various tables such as Employee, Project, and Book. Key operations include filtering employees by department, modifying salaries, and retrieving specific book titles based on conditions.

Uploaded by

ameyparab1105
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views5 pages

SQL Queries From Images

The document contains SQL queries related to employee management, project details, and book inventory. It includes commands for selecting, updating, and inserting data across various tables such as Employee, Project, and Book. Key operations include filtering employees by department, modifying salaries, and retrieving specific book titles based on conditions.

Uploaded by

ameyparab1105
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 5

SQL QUERIES FROM ALL IMAGES

IMAGE 1: Employee, Project, Department, Works

1) Project number and name for budget > 100000

SELECT pno, pname

FROM project

WHERE budget > 100000;

2) Employees (name only) in department 'D1' ordered by descending salary

SELECT ename

FROM employee

WHERE dno = 'D1'

ORDER BY salary DESC;

3) Works records where hours < 10 and responsibility = 'Manager'

SELECT *

FROM works

WHERE hours < 10 AND resp = 'Manager';

4) Employee names ending with letter 's'

SELECT ename

FROM employee

WHERE ename LIKE '%s';

5) Total number of employees

SELECT COUNT(*)
FROM employee;

6) Increase salary of employees by 10%

UPDATE employee

SET salary = salary * 1.10;

7) Employee name with maximum salary

SELECT ename

FROM employee

WHERE salary = (SELECT MAX(salary) FROM employee);

IMAGE 2: Employee, Works, Company, Manages

a) Modify so that 'John' lives in 'Mumbai'

UPDATE Employee

SET city = 'Mumbai'

WHERE empname = 'John';

b) Employees who joined in October

SELECT *

FROM Employee

WHERE MONTH(date_of_joining) = 10;

c) 10% raise for employees of 'ABC Corporation'

UPDATE Works

SET salary = salary * 1.10


WHERE company_name = 'ABC Corporation';

d) Employees who live in same cities as companies they work for

SELECT E.empname

FROM Employee E

JOIN Works W ON E.empname = W.empname

JOIN Company C ON W.company_name = C.company_name

WHERE E.city = C.city;

e) Employees earning more than average salary of their company

SELECT W.empname

FROM Works W

WHERE W.salary > (

SELECT AVG(W2.salary)

FROM Works W2

WHERE W2.company_name = W.company_name

);

IMAGE 3: Book, Store, Stock

i) Modify cost of DBMS books by 10%

UPDATE Book

SET cost = cost * 1.10

WHERE title LIKE '%DBMS%';

ii) Total number of books in Mumbai stores


SELECT SUM(S.quantity)

FROM Stock S

JOIN Store T ON S.store_no = T.store_no

WHERE T.city = 'Mumbai';

iii) Titles containing word 'System'

SELECT title

FROM Book

WHERE title LIKE '%System%';

iv) Title of most expensive book

SELECT title

FROM Book

WHERE cost = (SELECT MAX(cost) FROM Book);

v) Add new record in Book (example)

INSERT INTO Book (book_id, title, author, cost)

VALUES ('B101', 'DBMS Fundamentals', 'Navathe', 500);

IMAGE 4: Same as Image 2

1) Modify John?s city to Mumbai

UPDATE Employee

SET city = 'Mumbai'

WHERE empname = 'John';


2) Employees who joined in October

SELECT *

FROM Employee

WHERE MONTH(date_of_joining) = 10;

3) 10% raise for ABC Corp

UPDATE Works

SET salary = salary * 1.10

WHERE company_name = 'ABC Corporation';

4) Employees earning more than avg salary of their company

SELECT W.empname

FROM Works W

WHERE W.salary > (

SELECT AVG(W2.salary)

FROM Works W2

WHERE W2.company_name = W.company_name

);

5) Companies starting with 'A'

SELECT company_name

FROM Company

WHERE company_name LIKE 'A%';

You might also like