0% found this document useful (0 votes)
2 views13 pages

IP Practical File(MySQL)

The document contains SQL queries related to a MOVIE database, including commands to display movie information, calculate earnings, filter by production costs, and select specific movie types. It also includes queries for basic mathematical operations, string manipulations, and date formatting. Additionally, it describes creating a SPORTS database and TEAM table, as well as queries for a STOCK table to display items and summarize quantities.

Uploaded by

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

IP Practical File(MySQL)

The document contains SQL queries related to a MOVIE database, including commands to display movie information, calculate earnings, filter by production costs, and select specific movie types. It also includes queries for basic mathematical operations, string manipulations, and date formatting. Additionally, it describes creating a SPORTS database and TEAM table, as well as queries for a STOCK table to display items and summarize quantities.

Uploaded by

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

Q1. Consider the following MOVIE table and write the SQL queries based on it.

a) Display all information from movie.


b) Display the type of movies.
c) Display movieid, moviename, total_eraning by showing the business done by the
movies. Calculate the business done by movie using the sum of productioncost and
businesscost.
d) Display movieid, moviename and productioncost for all movies with productioncost
greater than 150000 and less than 1000000.
e) Display the movie of type action and romance.
f) Display the list of movies which are going to release in February, 2022.

1
ANSWER:

create database cinema;

use cinema;

create table MOVIE(Movie_ID char(5) primary key not null,MovieName varchar(20),Type


varchar(15),ReleaseDate date,ProductionCost int,BusinessCost int);

insert into MOVIE values('M001','The Kashmir Files','Action','2022-01-


26',1245000,1300000),('M002','Attack','Action','2022-01-28',1120000,1250000),
('M003','Looop Lapeta','Thriller','2022-02-01',250000,300000),('M004','Badhai
Do','Drama','2022-02-04',720000,68000),('M005','Shabaash Mithu','Biography','2022-02-
04',1000000,800000),('M006','Gehraiyaan','Romance','2022-02-11',150000,120000);

a) select * from MOVIE;

b) select Type from MOVIE;

2
c) select Movie_ID,MovieName,ProductionCost+BusinessCost as 'Total_Earning' from
MOVIE;

d) select Movie_ID,MovieName,ProductionCost from MOVIE where


ProductionCost>150000 and ProductionCost<1000000;

e) select MovieName from MOVIE where month(ReleaseDate)=2;

f) select MovieName from MOVIE where Type in('Action','Romance');

3
Q2. Write following queries:
a) Write a query to display cube of 5.
b) Write a query to display the number 563.854741 rounding off to the next hundred.
c) Write a query to display “put” from the word “Computer”.
d) Write a query to display today’s date into DD.MM.YYYY format.

4
ANSWER:

a) select pow(5,3);

b) select round(563.854741,-3);

c) select mid('computer',4,3);

d) select concat(day(now()), concat('.',month(now()), concat('.',year(now())))) "Date";

5
Q3. Write following queries:
a) Write a query to display ‘DIA’ from the word ‘MEDIA’.
b) Write a query to display moviename - type from the table movie.
c) Write a query to display first four digits of productioncost.
d) Write a query to display last four digits of businesscost.
e) Write a query to display weekday of release dates.
f) Write a query to display dayname on which movies are going to be released.

6
ANSWER:

a) select mid('MEDIA',3);

use cinema;

b) select concat(moviename,concat(' - ',type)) from movie;

c) select left(productioncost,4) from movie;

d) select right(businesscost,4) from movie;

7
e) select weekday(ReleaseDate) from MOVIE;

f) select dayname(ReleaseDate) from MOVIE;

8
Q4. Suppose your school management has decided to conduct cricket matches between
students of Class XI and Class XII. Students of each class are asked to join any one
of the four teams – Team Titan, Team Rockers, Team Magnet and Team Hurricane.
During summer vacations, various matches will be conducted between these teams.
Help your sports teacher to do the following:
a) Create a database “Sports”.
b) Create a table “TEAM” with following considerations:
i. It should have a column TeamID for storing an integer value between 1 to 9, which
refers to unique identification of a team.
ii. Each TeamID should have its associated name (TeamName), which should be a
string of length not less than 10 characters.
iii. Using table level constraint, make TeamID as the primary key.
c) Show the structure of the table TEAM using a SQL statement.
d) Show the contents of the table TEAM using a DML statement.

9
ANSWER:

a) create database sports;

use sports;

b) create table team(TeamID int(1),TeamName varchar(20),primary key(TeamID));

insert into team values(1,'Team Titan');

insert into team values(2,'Team Rockers');

insert into team values(3,'Team Magnet');

insert into team values(4,'Team Hurricane');

c) desc team;

d) select * from team;

10
Q5. Consider the following table and write the queries:
a) Display all the items in the ascending order of stockdate.
b) Display maximum price of items for each dealer individually as per dcode from
stock.
c) Display the sum of quantity for each dcode.

11
ANSWER:

create database store;

use store;

create table stock(TeamNo char(5) primary key not null,Item varchar(15),Dcode int,
Qty int,UnitPrice int,StockDate date);

insert into stock values('S005','Ballpen',102,100,10,'2018-04-22'),


('S003','Gel Pen',101,150,15,'2018-03-18'),
('S002','Pencil',102,125,5,'2018-02-25'),
('S006','Eraser',101,200,3,'2018-01-12'),
('S001','Sharpner',103,210,5,'2018-06-11'),
('S004','Compass',102,60,35,'2018-05-10'),
('S009','A4 Papers',102,160,5,'2018-07-17');

a) select * from stock order by StockDate;

b) select sum(Qty) from stock group by Dcode;

12
c) select sum(Qty),Dcode from stock group by Dcode;

13

You might also like