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

แชร์
ฝัง
  • เผยแพร่เมื่อ 15 ต.ค. 2024
  • 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 Aggregat...
    Most Asked Join Based Interview Question:
    • Most Asked SQL JOIN ba...
    Solving 4 Trick SQL problems:
    • Solving 4 Tricky SQL P...
    Data Analyst Spotify Case Study:
    • Data Analyst Spotify C...
    Top 10 SQL interview Questions:
    • Top 10 SQL interview Q...
    Interview Question based on FULL OUTER JOIN:
    • SQL Interview Question...
    Playlist to master SQL :
    • Complex SQL Questions ...
    Rank, Dense_Rank and Row_Number:
    • RANK, DENSE_RANK, ROW_...
    #sql #dataengineer

ความคิดเห็น • 74