0% found this document useful (0 votes)
16 views4 pages

Aushna SQL Project

The document contains SQL queries for analyzing Netflix titles from a database. It includes queries to count total movies and TV shows, find common ratings, list movies by release year, identify top countries with content, and more. The queries also address specific business problems related to content duration, directors, seasons, genres, and content added in recent years.

Uploaded by

sairaliaquat20
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)
16 views4 pages

Aushna SQL Project

The document contains SQL queries for analyzing Netflix titles from a database. It includes queries to count total movies and TV shows, find common ratings, list movies by release year, identify top countries with content, and more. The queries also address specific business problems related to content duration, directors, seasons, genres, and content added in recent years.

Uploaded by

sairaliaquat20
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/ 4

SELECT * FROM new_schema.

netflix_titles;

-- 10 Business Problems

1. Count total number of Movies and Tv shows in netflix

SELECT

type,

COUNT(*) as title

FROM new_schema.netflix_titles

GROUP BY type

2.Find the most common ratings for tv and movie shows

SELECT

type,

rating

FROM

(SELECT

type,

rating,

COUNT(*),

RANK() OVER(PARTITION by type ORDER BY COUNT(*) DESC) as ranking

FROM new_schema.netflix_titles

GROUP BY

type,rating)

as t1

WHERE

ranking =1
3.List all movies released in any specific year (eg:2020)

SELECT * FROM new_schema.netflix_titles

WHERE

type="Movie"

AND

release_year=2020

4. Find the top 5 countries with the most content on netflix

SELECT

TRIM(LOWER(jt.new_country)) AS new_country,

COUNT(nt.show_id) AS total_content

FROM

new_schema.netflix_titles nt,

JSON_TABLE(

CONCAT('["', REPLACE(nt.country, ',', '","'), '"]'),

'$[*]' COLUMNS (new_country VARCHAR(255) PATH '$')

) AS jt

GROUP BY

TRIM(LOWER(jt.new_country))

ORDER BY

total_content DESC

LIMIT 5;

5.Idnetify the longest movie?

SELECT MAX(duration)
FROM new_schema.netflix_titles

WHERE type = 'Movie'

6. Find content added inlast five years ?

SELECT

*,

STR_TO_DATE(date_added, '%M %d,%Y') AS formatted_date

FROM

new_schema.netflix_titles

WHERE

STR_TO_DATE(date_added, '%M %d,%Y') >= CURRENT_DATE() - INTERVAL 5 YEAR;

7.find all movies/tv shows directed by "Scott stewart"?

SELECT *FROM new_schema.netflix_titles

WHERE director LIKE "%Scott Stewart%" ;

8. list all the number of seasons which are greater than 5?

SELECT

*,

SUBSTRING_INDEX(duration, ' ', 1) AS seasons

FROM

new_schema.netflix_titles

WHERE
LOWER(type) = 'Tv Show'

AND CAST(SUBSTRING_INDEX(duration, ' ', 1) AS UNSIGNED) >5;

9. count the number of content items in each genre

SELECT

listed_in,

show_id,

SUBSTRING_INDEX(listed_in, ',', 1) AS first_category,

COUNT(show_id) AS total_content

FROM new_schema.netflix_titles

GROUP BY

listed_in,show_id;

10. list all the movies that are documentaries ?

SELECT *

FROM new_schema.netflix_titles

WHERE

LOWER(listed_in) LIKE '%documentaries%';

You might also like