#SQL

Publié le: 05 octobre 2024
sur la chaîne: The Code Samples
228
17

#SQL Leetcode SQL 50 #25: 1070:

Write a solution to select the product id, year, quantity, and price for the first year of every product sold.
Return the resulting table in any order.

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 sales table
CREATE TABLE sales (
sale_id INT,
product_id INT,
year INT,
quantity INT,
price DECIMAL(10, 2)
);

-- Insert data into the sales table
INSERT INTO sales (sale_id, product_id, year, quantity, price) VALUES
(1, 100, 2008, 10, 5000),
(2, 100, 2009, 12, 5000),
(7, 200, 2011, 15, 9000);

-- Create the product table
CREATE TABLE product (
product_id INT,
product_name VARCHAR(50)
);

-- Insert data into the product table
INSERT INTO product (product_id, product_name) VALUES
(100, 'Nokia'),
(200, 'Apple'),
(300, 'Samsung');

#datascience #coding #programming #mssql #databasemanagement #leetcode #leetcode1070 #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  


Sur cette page du site, vous pouvez voir la vidéo en ligne #SQL durée heure minute seconde en bonne qualité , qui a été Téléchargé par l'utilisateur The Code Samples 05 octobre 2024, Partagez le lien avec vos amis et connaissances, sur youtube cette vidéo a déjà été regardée 228 fois et il a aimé 17 téléspectateurs. Bon visionnage!