0% found this document useful (0 votes)
34 views6 pages

Dbms - Test4 Level3 Answers

The document contains descriptions of 12 use cases involving SQL queries on sample database tables. For each use case, it provides the relevant table structures, query requirements, and the SQL queries to meet those requirements. The key information is that the document provides examples of common SQL queries and operations like filtering, aggregation, joins, grouping and more, applied to sample database tables to demonstrate querying and updating of relational database tables.

Uploaded by

cse2023mantosh48
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)
34 views6 pages

Dbms - Test4 Level3 Answers

The document contains descriptions of 12 use cases involving SQL queries on sample database tables. For each use case, it provides the relevant table structures, query requirements, and the SQL queries to meet those requirements. The key information is that the document provides examples of common SQL queries and operations like filtering, aggregation, joins, grouping and more, applied to sample database tables to demonstrate querying and updating of relational database tables.

Uploaded by

cse2023mantosh48
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/ 6

Dbms_Test4-Level3:

UseCase7:In a database there are two tables "ITEM" and "CUSTOMER" as shown
below :

Write the command in SQL for the following :


(i) To display the details of the items whose Price is in the range of 40 and 95 (Both
values included).
(ii) To display the CustomerName, City from table Customer and ItemName and Price
from table Item with their corresponding matching ID'
(iii) To increase the price of all the products by 50.

(i) SELECT * FROM ITEM WHERE PRICE > = 40 AND PRICE <=95.
(ii) SELECT CUSTOMERNAME, CITY,ITEMNAME, PRICE FROM CUSTOMER, ITEM
WHERE CUSTOMER.ID = ITEM.ID.
(iii) UPDATE ITEM SET PRICE = PRICE + 50.
UseCase8: Given below is the 'Worker' table :

INSERT INTO WORKER VALUES (105, 'Heena Prabha');


Commit;
UPDATE WORKER SET Name 'Tarun' where WID = 101;
SAVEPOINT A;
INSERT INTO WORKER VALUES (206,'Raj Kumar');
SAVEPOINT B;
INSERT INTO WORKER VALUES (107,'John Ken');
SAVEPOINT C;
ROLLBACK TO B;
What will be the output of the following statement after the above ROLLBACK ?
SELECT * FROM WORKER;
WID NAME
101 Tarun
204 Fardeen Khan
105 Heena Prabha
206 Raj Kumar
UseCase9:In a database BANK, there are two tables with a sample data given below :

Write SQL queries for the following :


(i) To display ENO, ENAME, SALARY and corresponding DNAME of all the employees
whose age is between 25 and 35 (both inclusive)
(ii) To display DNAME and corresponding ENAME from both tables. Hint: HOD of the
DEpARTMENT table should be matched with ENO of the Employee table for getting
desired result.
(iii) To display ENAME, SALARY ZONE and INCOME TAX (30% of salary) of all the
employees with appropriate column headings.
(i) SELECT C.ENQ, C.ENAME, C.SALARY FROM EMPLOYEE C, DEPARTMENT D
WHERE C.DEPT : D.DEpT AND C.AGE>:25 && C.AGE <:35;
(ii) SELECT D.DNAME,C.ENAME FROM EMPLOYEE C, DEPARTMENT D WHEREC.
DEPT=D.DEPT AND C.ENO : D.HOD;
(iii) SELECT ENAME, SALARY ZONE,SALARY*0.3 AS "income tax" FROM
EMPLOYEE;
UseCase10:In a Database Multiplexes, there are two tables with the following data. Write
MySQL queries for (i) to (iii), which are based on TicketDetails and AgentDetails

(i) To display Tcode, Name and Aname of all the records where the number of tickets
sold is more than 5.
(ii) To display total number o{ tickets booked by agent "Mr. Ayush".
(iii) To display Acode, Aname and corresponding Tcode where Aname ends with 'k'.

(i) SELECT Tcode, Name, AName from TicketDetails, AgentDetails where


TicketDetails.ACode = AgentDetails.Acode and Tickets > 5.
(ii) SELECT COUNT(Tickets) FROM TicketDetails, AgentDetails where
TicketDetails.ACode = AgentDetails"Acode and AName like "Mr. Ayush";
(iii) SELECT Tcode, Name, AName from TicketDetails, AgentDetails where
TicketDetails.ACode = AgentDetails.Acode and Aname like"%k";
UseCase11:Consider the tables'Flights' & 'Fares' given below:

With reference to these tables, write commands in SQL for (i) and (ii) and output for (iii)
below:
(i) To display flight number source, airlines of those flights where fare is less than Rs.
10000.
(ii) To count total no of Indian Airlines flights starting from various cities.
(iii) SELECT FLIGFITS.FNO, NO_OF_FL, AIRLINES FROM FLIGHTS,FARES WHERE
FLIGHTS. FNO = FARES.FNO AND SOURCE='DELHI';

(i) select flights.fno,source,airlines from flights,fares where flight.fno=fares.fno


and fare < 10000;
(ii) select sum(no_of_fl) from flights,fares where flights.fno=fares.fno group by
source having Airlines ='Indian Airlines';
(iii) MC101 6 Deccan Airlines MU499 3 Sahara
UseCase12:Consider the table 'Company'. XYZ wanted to display the highest salary of
each department along with department names.

Select Department, MAX (Salary) From Company Group BY Department;

You might also like