#SQL

Опубликовано: 31 Декабрь 2024
на канале: The Code Samples
173
13

#SQL Leetcode SQL 50 #21: 1174:
Write a solution to find the percentage of immediate orders in the first orders of all customers, rounded to 2 decimal places. If the customer's preferred delivery date is the same as the order date, then the order is called immediate; otherwise, it is called scheduled.

The first order of a customer is the order with the earliest order date that the customer made. It is guaranteed that a customer has precisely one first order. We will be using subquery to solve this.

We will be solving all the questions from LeetCode SQL 50 one by one. These questions range from easy to hard.

**SQL scripts you can use to create and populate the table:
-- Create the Delivery table
CREATE TABLE Delivery (
delivery_id INT,
customer_id INT,
order_date DATE,
customer_pref_delivery_date DATE
);

-- Insert data into the Delivery table
INSERT INTO Delivery (delivery_id, customer_id, order_date, customer_pref_delivery_date) VALUES
(1, 1, '2019-08-01', '2019-08-02'),
(2, 2, '2019-08-02', '2019-08-02');

#datascience #coding #programming #mssql #databasemanagement #leetcode #leetcode1174 #leetcodesolution

👉SQL Tutorials Playlist:
   • SQL Tutorials  

👉SQL Shorts Playlist:
   • SQL Shorts  

👉Python Shorts Playlist:
   • Playlist  

👉Python Tutorials Playlist:
   • Python Tutorials  

👉Excel Shorts Playlist:
   • Excel Shorts