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

CS Report File Solutions (19-23)

Uploaded by

Naruto Uzumaki
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)
26 views5 pages

CS Report File Solutions (19-23)

Uploaded by

Naruto Uzumaki
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

CS Report File

Q19) SQL Queries for Employee and Job Tables:

1. Display employee IDs, names of employees, job IDs with corresponding job titles:

SELECT Employee.ID, Employee.Name, Employee.JobID, Job.JobTitle


FROM Employee
JOIN Job
ON Employee.JobID = Job.JobID;

2. Display names of employees, sales, and corresponding job titles for sales over 1,300,000:

SELECT Employee.Name, Employee.Sales, Job.JobTitle


FROM Employee
JOIN Job
ON Employee.JobID = Job.JobID
WHERE Employee.Sales > 1300000;

3. Display names and job titles of employees with 'Singh' in their names:

SELECT Employee.Name, Job.JobTitle


FROM Employee
JOIN Job
ON Employee.JobID = Job.JobID
WHERE Employee.Name LIKE '%Singh%';

4. Identify the foreign key in the table:


● The foreign key is Employee.JobID referencing Job.JobID.
5. Change the JOBID to 104 for the Employee with ID 'E4':

UPDATE Employee
SET JobID = 104
WHERE ID = 'E4';

Q20) SQL Queries for Student Table Operations:

1. Add a new field (column) 'school_name' of datatype varchar(50):

ALTER TABLE Student


ADD school_name VARCHAR(50);

2. Update 'school_name' as 'ABC Public School':

UPDATE Student
SET school_name = 'ABC Public School';

3. Display all records in ascending order of class:

SELECT *
FROM Student
ORDER BY class ASC;

4. Delete records where game is 'basketball':

DELETE FROM Student


WHERE game = 'basketball';

5. Display the total number of students in each game:

SELECT game, COUNT(*) AS Total_Students


FROM Student
GROUP BY game;

Q21) SQL Commands for SENDER and RECIPIENT Tables:

1. Display names of all Senders from Mumbai:

SELECT SenderName
FROM SENDER
WHERE SenderCity = 'Mumbai';

2. Display RecID, SenderName, SenderAddress, RecName, RecAddress for every Recipient:

SELECT RECIPIENT.RecID, SENDER.SenderName, SENDER.SenderAddress, RECIPIENT.RecName,


RECIPIENT.RecAddress
FROM RECIPIENT
JOIN SENDER
ON RECIPIENT.SenderID = SENDER.SenderID;
3. Display Recipient details in ascending order of RecName:

SELECT *
FROM RECIPIENT
ORDER BY RecName ASC;

4. Display number of Recipients from each city:

SELECT RecCity, COUNT(*) AS Total_Recipients


FROM RECIPIENT
GROUP BY RecCity;

5. Display details of Recipients from Mumbai:

SELECT *
FROM RECIPIENT
WHERE RecCity = 'Mumbai';

Q22) SQL Queries for Student Table Operations:

1. Display all unique game names:

SELECT DISTINCT game


FROM Student;

2. Display names of students whose names start with 'A':

SELECT Name
FROM Student
WHERE Name LIKE 'A%';

3. Display names of students with a 'C' grade in Game or SUPW:

SELECT Name
FROM Student
WHERE GameGrade = 'C' OR SUPWGrade = 'C';

4. Insert a record into the 'Student' table:


INSERT INTO Student (ID, Class, Name, Game, GameGrade, SUPW, SUPWGrade)
VALUES (16, 9, 'Bipluv', 'Cricket', 'A', 'Cooking', 'A');

5. Add a column 'Wing' to the table:

ALTER TABLE Student


ADD Wing VARCHAR(10);

Q23) SQL Query Outputs Based on TRANSPORT and TRIP Tables:

1. Sum of KM for TCODE >= 104:

SELECT SUM(KM)
FROM TRIP
WHERE TCODE >= 104;

2. Count of TCODEs grouped by TCODE where count > 1:

SELECT COUNT(*), TCODE


FROM TRIP
GROUP BY TCODE
HAVING COUNT(*) > 1;

3. Display distinct TCODE from TRIP:

SELECT DISTINCT TCODE


FROM TRIP;

4. Display TCODE, NAME, TTYPE for trips with KM < 90:

SELECT A.TCODE, NAME, TTYPE


FROM TRIP A, TRANSPORT B
WHERE A.TCODE = B.TCODE AND KM < 90;

5. Calculate and display NAME and cost (KM * PERKM) for TCODE 105:

SELECT NAME, KM * PERKM AS Cost


FROM TRIP A, TRANSPORT B
WHERE A.TCODE = B.TCODE AND A.TCODE = 105;

You might also like