R
@Roopesh122
Netflix Movies DataSet
CREATE TABLE Netflix_Movies (
Movie_ID INT PRIMARY KEY,
Movie_Title VARCHAR(100),
Director_Name VARCHAR(100),
Cast VARCHAR(255),
Country VARCHAR(100),
Date_Added DATE,
Release_Year INT,
Rating DECIMAL(4,2),
Genres VARCHAR(100),
Netflix Movies DataSet
CREATE TABLE Netflix_Movies(
Movie_ID INTEGER NOT NULL PRIMARY KEY
,Movie_Title VARCHAR(46) NOT NULL
,Director_Name VARCHAR(30) NOT NULL
,Cast VARCHAR(94) NOT NULL
,Country VARCHAR(55) NOT NULL
,Date_Added DATE NOT NULL
,Release_Year INTEGER NOT NULL
,Rating NUMERIC(4,2) NOT NULL
,Genres VARCHAR(45) NOT NULL
Tech Layoffs
CREATE TABLE Tech_Layoffs (
Layoff_ID INT PRIMARY KEY,
Company_ID INT,
Company_Name VARCHAR(30),
Location VARCHAR(30),
HeadQuarter VARCHAR(10),
LaidOff INT,
Layoff_Date DATE,
Layoff_Percentage DECIMAL(4,2),
Industry VARCHAR(20),
SQL Interview Q80
/*
Morgan Stanley SQL Interview Question
A vaccine is administered in two doses. It is best if the doses are given between 42 and 72 days apart, inclusive.
Write a SQL query to return the percentage of beneficiaries who received both doses within the recommended time period, rounded to the nearest and Vaccination_Date
*/
-- Schema Setup
CREATE TABLE Doses (
SQL Interview Q79
/*
Walmart SQL Interview Question
Write a SQL query to output the names of those students whose best friends got higher salary package than student.
*/
-- Schema Setup
Create Table Students_Tbl (Id int,
Student_Name Varchar(30));
SQL Interview Q78
/*
Netflix SQL Interview Question
Identify VIP Users for Netflix
To better cater to its most dedicated users, Netflix would like to identify its "VIP users" - those who are most active in terms of the number of hours of content they watch.
Write a SQL query that will retrieve the top 2 users with the most watched hours in the last month.
*/
-- Schema Setup
SQL Interview Q77
/*
Amazon SQL Interview Question
You are working with a table called Orders that tracks customer orders with their order dates and amounts.
Write a query to find each customer’s latest order amount along with the amount of the second latest order.
*/
-- Schema Setup
CREATE TABLE orders (
order_id INT,
SQL Interview Q76
/*
Paypal SQL Interview Question
Write a SQL query to determine the number of unique two-way money transfer relationships,
where a two-way relationship is established if a user has sent money to another user and also received money from the same user.
*/
-- Schema Setup
CREATE TABLE payments (
payer_id INT,
SQL Interview Q75
/*
Paypal SQL Interview Question
Write a SQL query to retrieve the final account balance for each account by calculating the net amount from deposits and withdrawals.
*/
-- Schema Setup
CREATE TABLE transactions (
transaction_id INT PRIMARY KEY,
account_id INT,
SQL Interview Q74
/*
City of San Francisco SQL Interview Question
Find the number of words in each business name.
Avoid counting special symbols as words (e.g. &). Output the business name and its count of words.
*/
-- Schema Setup
CREATE TABLE sf_restaurant_health_violations ( business_address VARCHAR(255), business_city VARCHAR(100), business_id BIGINT, business_latitude FLOAT, business_location VARCHAR(255), business_longitude FLOAT, business_name VARCHAR(255), business_phone_number BIGINT, business_pos
SQL Interview Q73
/*
Amazon SQL Interview Question
You are given a table of tennis players and their matches that they could either win (W) or lose (L).
Find the longest streak of wins. A streak is a set of consecutive won matches of one player. The streak ends once a player loses their next match.
Output the ID of the player or players and the length of the streak.
*/
SQL Interview Q72
/*
Google SQL Interview Question
We want to identify the most suspicious claims in each state.
We'll consider the top 5 percentile of claims with the highest fraud scores in each state as potentially fraudulent.
*/
-- Schema Setup
CREATE TABLE claims (policy_number VARCHAR(50), state VARCHAR(50), claim_cost FLOAT, fraud_score FLOAT);
SQL Interview Q71
/*
Goldman Sachs SQL Interview Question
You are given a list of exchange rates from various currencies to US Dollars (USD) in different months. Show how the exchange rate of all the currencies changed in the first half of 2020. Output the currency code and the difference between values of the exchange rate between July 1, 2020 and January 1, 2020.
*/
-- Schema Setup
CREATE TABLE sf_exchange_rates ( date DATETIME, exchange_rate FLOAT, source_currency VARCHAR(10), target_currency VARCHAR(10
SQL Interview Q70
/*
Microsoft SQL Interview Question
Considering a dataset that tracks user interactions with different clients, identify which clients have users who are exclusively loyal to them (i.e., they don't interact with any other clients).
For each of these clients, calculate the number of such exclusive users. The output should include the client_id and the corresponding count of exclusive users.
*/
-- Schema Setup
CREATE TABLE meetup_events (client_id VARCHAR(255), customer_id VARCHAR(255), ev
SQL Interview Q69
/*
Amazon SQL Interview Question
You have a table of in-app purchases by user. Users that make their first in-app purchase are placed in a marketing campaign where they see call-to-actions for more in-app purchases.
Find the number of users that made additional in-app purchases due to the success of the marketing campaign.
The marketing campaign doesn't start until one day after the initial in-app purchase so users that only made one or multiple purchases on the first day do not count, nor d
SQL Interview Q68
/*
ESPN SQL Interview Question
Find the quarterback who threw the longest throw in 2016. Output the quarterback name along with their corresponding longest throw.
The 'lg' column contains the longest completion by the quarterback.
*/
-- Schema Setup
CREATE TABLE qbstats_2015_2016 (att INT, cmp INT, game_points INT, home_away VARCHAR(10), intt INT, lg VARCHAR(10), loss INT, qb VARCHAR(40), rate FLOAT, sack INT, td INT, yds INT, year INT, ypa FLOAT);
SQL Interview Q67
/*
Google SQL Interview Question
Find the top 3 most common letters across all the words from both the tables (ignore filename column).
Output the letter along with the number of occurrences and order records in descending order based on the number of occurrences.
*/
-- Schema Setup
CREATE TABLE google_file_store (contents VARCHAR(100), filename VARCHAR(255));
SQL Interview Q66
/*
Amazon SQL Interview Question
Find the 3-month rolling average of total revenue from purchases given a table with users, their purchase amount, and date purchased. Do not include returns which are represented by negative purchase values.
Output the year-month (YYYY-MM) and 3-month rolling average of revenue, sorted from earliest month to latest month.
A 3-month rolling average is defined by calculating the average total revenue from all user purchases for the current month and previous two
SQL Interview Q65
/*
Meta SQL Interview Question
The sales department has given you the sales figures for the first two months of 2023.
You've been tasked with determining the percentage of weekly sales on the first and last day of every week. Consider Sunday as last day of week and Monday as first day of week.
In your output, include the week number, percentage sales for the first day of the week, and percentage sales for the last day of the week. Both proportions should be rounded to the nearest whole number
SQL Interview Q64
/*
DoorDash SQL Interview Question
Calculate the average net earnings per order grouped by weekday (in text format, e.g., Monday) and hour from customer_placed_order_datetime.
The net earnings are computed as: order_total + tip_amount - discount_amount - refunded_amount. Round the result to 2 decimals.
*/
-- Schema Setup
CREATE TABLE doordash_delivery (consumer_id BIGINT, customer_placed_order_datetime DATETIME, delivered_to_consumer_datetime DATETIME, delivery_region NVARCHAR(255), disc