15 YouTube views, likes subscribers in 10 minutes. Free!
Get Free YouTube Subscribers, Views and Likes

Honeywell SQL Interview Question | Print Movie Stars (⭐ ⭐ ⭐ ⭐⭐) For best movie in each Genre

Follow
Ankit Bansal

In this video we will discuss solution of a SQL interview problem asked in Honeywell interview. Here is the script:

CREATE TABLE movies (
id INT PRIMARY KEY,
genre VARCHAR(50),
title VARCHAR(100)
);

Create reviews table
CREATE TABLE reviews (
movie_id INT,
rating DECIMAL(3,1),
FOREIGN KEY (movie_id) REFERENCES movies(id)
);

Insert sample data into movies table
INSERT INTO movies (id, genre, title) VALUES
(1, 'Action', 'The Dark Knight'),
(2, 'Action', 'Avengers: Infinity War'),
(3, 'Action', 'Gladiator'),
(4, 'Action', 'Die Hard'),
(5, 'Action', 'Mad Max: Fury Road'),
(6, 'Drama', 'The Shawshank Redemption'),
(7, 'Drama', 'Forrest Gump'),
(8, 'Drama', 'The Godfather'),
(9, 'Drama', 'Schindler''s List'),
(10, 'Drama', 'Fight Club'),
(11, 'Comedy', 'The Hangover'),
(12, 'Comedy', 'Superbad'),
(13, 'Comedy', 'Dumb and Dumber'),
(14, 'Comedy', 'Bridesmaids'),
(15, 'Comedy', 'Anchorman: The Legend of Ron Burgundy');

Insert sample data into reviews table
INSERT INTO reviews (movie_id, rating) VALUES
(1, 4.5),
(1, 4.0),
(1, 5.0),
(2, 4.2),
(2, 4.8),
(2, 3.9),
(3, 4.6),
(3, 3.8),
(3, 4.3),
(4, 4.1),
(4, 3.7),
(4, 4.4),
(5, 3.9),
(5, 4.5),
(5, 4.2),
(6, 4.8),
(6, 4.7),
(6, 4.9),
(7, 4.6),
(7, 4.9),
(7, 4.3),
(8, 4.9),
(8, 5.0),
(8, 4.8),
(9, 4.7),
(9, 4.9),
(9, 4.5),
(10, 4.6),
(10, 4.3),
(10, 4.7),
(11, 3.9),
(11, 4.0),
(11, 3.5),
(12, 3.7),
(12, 3.8),
(12, 4.2),
(13, 3.2),
(13, 3.5),
(13, 3.8),
(14, 3.8),
(14, 4.0),
(14, 4.2),
(15, 3.9),
(15, 4.0),
(15, 4.1);

Zero to hero(Advance) SQL Aggregation:
   • All About SQL Aggregations | SQL Adva...  

Most Asked Join Based Interview Question:
   • Most Asked SQL JOIN based Interview Q...  

Solving 4 Trick SQL problems:
   • Solving 4 Tricky SQL Problems  

Data Analyst Spotify Case Study:
   • Data Analyst Spotify Case Study | SQL...  

Top 10 SQL interview Questions:
   • Top 10 SQL interview Questions and An...  

Interview Question based on FULL OUTER JOIN:
   • SQL Interview Question Based on Full ...  

Playlist to master SQL :
   • Complex SQL Questions for Interview P...  

Rank, Dense_Rank and Row_Number:
   • RANK, DENSE_RANK, ROW_NUMBER SQL Anal...  

#sql #dataengineer

posted by skuffanmy