SQL Queries

Download as pdf or txt
Download as pdf or txt
You are on page 1of 11

SQL QUERIES USING

ONE TABLE
Consider the following MOVIE table and write
the SQL queries based on it:-

Movie_ID MovieName Type ReleaseDate ProductionCost BusinessCost

The Kashmir
M001 Action 2022/01/26 1245000 1300000
Files

M002 Attack Action 2022/01/28 1120000 1250000

Looop
M003 Thriller 2022/02/01 250000 300000
Lapeta

M004 Badhai Do Drama 2022/02/04 720000 68000

Shabaash
M005 Biography 2022/02/04 1000000 800000
Mithu

M006 Gehraiyaan Romance 2022/02/11 150000 120000


Questions-

1. Display all information from movie.


2. Display the type of movies.
3. Display movieid, moviename, total_eraning by
showing the business done by the movies. Claculate
the business done by movie using the sum of
productioncost and businesscost.
4. Display movieid, moviename and productioncost for
all movies with productioncost greater thatn 150000
and less than 1000000.
5. Display the movie of type action and romance.
6. Display the list of movies which are going to release
in February, 2022.

Answers-
[1] select * from movie;

Output:
[2] select distinct from a movie;

Output:

[3] select movieid, moviename, productioncost +


businesscost “total earning” from movie;

Output:
[4] select movie_id,moviename, productioncost from
movie where producst is >150000 and <1000000;

Output:

[5] select moviename from movie where type =’action’ or


type=’romance’;

Output:
[6] select moviename from moview where
month(releasedate)=2;

Output:
Questions:
1. Write a query to display cube of 5.
2. Write a query to display the number 563.854741 rounding off
to the next hundred.
3. Write a query to display “put” from the word “Computer”.
4. Write a query to display today’s date into DD.MM.YYYY
format.
5. Write a query to display ‘DIA’ from the word “MEDIA”.
6. Write a query to display moviename – type from the table
movie.
7. Write a query to display first four digits of productioncost.
8. Write a query to display last four digits of businesscost.
9. Write a query to display weekday of release dates.

10.Write a query to display dayname on which movies are going


to be released.

Answers:

[1] select pow(5,3);

Output:
[2] select round(563.854741,-2);

Output:

[3] select mid(“Computer”,4,3);

Output:
[4] Select
concat(day(now()),concat(‘.’,month(now()),concat(‘.’,year(n
ow())))) “Date”;

Output:

[5] select right(“Media”,3);

Output:
[6] select concat(moviename,concat(‘ – ‘,type)) from movie;

Output:

[7] select left(productioncost,4) from movie;

Output:
[8] select right(businesscost,4) from movie;

Output:

[9] select weekday(releasedate) from movie;

Output:
[10] select dayname(releasedate) from movie;

Output:

You might also like