0% found this document useful (0 votes)
11 views

cs 12 assignment

Uploaded by

Tushar X E
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)
11 views

cs 12 assignment

Uploaded by

Tushar X E
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/ 12

COMPUTER SCIENCE ASSIGNMENT

~Consider the table Projects given below. Write commands in SQL


for i to iv and output for v to viii PROJECTS~

i)To display all information about projects of Medium ProjSize


Ans : SELECT * FROM projects WHERE ProjSize="Medium";
ii) To list the ProjSize of projects whose ProjName ends with LITL.
Ans: SELECT ProjSize FROM projects WHERE ProjName LIKE "%LITL";
iii) To list ID, name, size and cost of all the projects in descending order of startDate.
Ans: SELECT ID,ProjName, ProjSize, Cost FROM projects ORDER BY startdate
DESC;
iv) To count the number of projects of cost less than 100000.
Ans: SELECT count(*) FROM projects WHERE cost<100000;
v) SELECT sum(Cost) FROM projects.
Ans: 980000
vi) SELECT DISTINCT(Projsize) FROM projects.

vii) SELECT MAX(Cost) FROM projects.


viii) SELECT AVG(Salary) FROM projects group by ProjSize.

Q2 Consider the table DOCTORS and PATIENTS given below

With reference to these tables, write commands in SQL for (i) and (ii) and output for (iii)
below.
(i) Display the PatNo, PatName, and corresponding DocName for each patient.
SELECT PatNo,PatName,DoName FROM patients, doctors WHERE patients
DocID=doctors.DocID;
(ii) Display the list of all patients whoseOPD_days are MWF.
(ii)-> select p.patho,p.patname,d.docname
-> from pateints p
-> join doctors d on p.docID = d.docID
-> where d.opd_days= ‘MWF’;
(iii) Display patient details of EnTand Ortho patients

(iv) Display pateints whose name starts with “M”

(v) Select OPD_Days, Count(*) From Doctors, Patients Where Patients.Department =


Doctors.DepartmentGroup by OPD_Days

Q3 Write SQL commands for statements (i) to (vi) and give output for SQL queries (vii) to (x)
on the basis of the table FAMILY:
(i) To display the name of all those where Male members are more than 3.
Ans: ->select name
->from family
-> where Male members>3;
(ii) To display the total female members of occupation business.
-> select sum ( FemaleMembers) as totalfemalemembers
-> from family
-> where Occupation = ‘business’;
(iii) To show the occupation of all those members whose income is between 75000 to
110000.
select name, occupation
-> from family
-> where income between 75000 and 110000;
(iv) To list the total no of female members which have an ‘o’ in their name.
select sum(femalemembers)as totalfemalememberswith0
-> from family
-> where name like’%o%’ and FemaleMembers> 0;
(v) To arrange the table in the descending order of income.
select*
-> from family
-> order by income DESC;
(vi)To insert a new record in the Family table with the following data:
9,’D’souza’,2,1,15000,’Service’.
-> INSERT INTO FAMILY (No, name, femalemembers, malemembers, income, occupation)
-> VALUES (9,’D’souza’,2,1,15000,’Service’);
(vii)SELECT MIN(DISTINCT Income) FROM Family;

(viii)SELECT MIN(Female Members) FROM Family WHERE Occupation = ‘Mixed’;

(ix)SELECT Occupation ,SUM( Income) FROM Familygroup by Occupation ;

(x) SELECT AVG( Income) FROM Family;


(c) Consider the table STUDENT given below, write SQL Commands for (i) to (iii) and output
for (iv) to (vi)

(i) To Display all information about class XII students


SELECT* FROM students WHERE Class = ‘XII’;
(ii) List names all class of all students in descending order of DOB.
SELECT Name, class FROM students ORDER by DOB DESC;
(iii) To count the number of student in XII Class of Mumbai city.
Select count(*) FROM students WHERE class ‘XII’ and City =’mumbai’;
(iv) SELECT DISTINCT(Sex) FROM Student.
(v) SELECT AVERAGE(Marks) FROM Student GROUP BY Sex.

(vi) SELECT COUNT(*)FROM Student where Class = ‘XI’

c) Consider the table Flight given below, write command in SQL for (1) to (4) and output for
(5) to (8). Table : FLIGHT

(1) To display Flight flying between Varanasi and Nepal.


Select* from flight where origin = ‘varanasi’ and destination = ‘nepal’;
(2) To display the different Origin of Flights
Select distinct origin from flight;
(3) To display list of flights in descending order of Rate
SELECT* FROM FLIGHT ORDER BY RATE DESC;
(4) To display flight details of the flight whose flightdate is after Jan 2008.
SELECT* FROM FLIGHT WHERE FLIGHTDate > ‘2008-01-31’;
(5) SELECT Flight_No, Destination FROM Flight WHERE Destination LIKE ‘_u%’;
(6) SELECT Origin, COUNT(*) FROM Flight GROUP BY Origin;

(7) SELECT Origin, Destination FROM Flight WHERE seats>400;

(8) SELECT SUM(Rate),MAX( Seats) FROM Flight;

f) Consider the table CARDEN and give the output of the following queries: Table: CARDEN
i) SELECT CarName FROM CARDEN where Color LIKE ‘%r’;

ii) Select Color FROM CARDEN whereCarName LIKE ‘I%’;

Q2. a) Write SQL Statement to create a table INVENTORY with the following structure:
Column ,Name ,Data Type Code- Decimal -4 ,Name -Varchar -15, Company- Varchar -15,
Price -Decimal-6, Quantity -Decimal- 4
b) Consider the following table and answer the following:

i. Identify the Primary key and the candidate key in the above table.
ii. Write MySQL query to add a column Diagnosis with data type Varchar and size 35 in the
table Patient.

c) Consider the table GARMENTS with the following data and answer the question that
follows:-

i. Display the details of Garments in ascending order of Price.


ii. Display Brand and Price of Category “Trouser”.

iii. Display the Category and price of all the products manufactured by Peter England.
iv. Increase the price of the entire Category by 5%.

v. Add a new record with following data values: ‘TS421’, ‘T-Shirt’, NULL, 1000, ‘2012-05-20’

vi. Remove the details of all the garments of Levis brand.

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