IP Practical File(MySQL)
IP Practical File(MySQL)
1
ANSWER:
use cinema;
2
c) select Movie_ID,MovieName,ProductionCost+BusinessCost as 'Total_Earning' from
MOVIE;
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);
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;
7
e) select weekday(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:
use sports;
c) desc 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:
use store;
create table stock(TeamNo char(5) primary key not null,Item varchar(15),Dcode int,
Qty int,UnitPrice int,StockDate date);
12
c) select sum(Qty),Dcode from stock group by Dcode;
13