#SQL

Publicado em: 05 Outubro 2024
no canal de: 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  


Nesta página do site você pode assistir ao vídeo on-line #SQL duração hora minuto segundo em boa qualidade , que foi baixado pelo usuário The Code Samples 05 Outubro 2024, compartilhe o link com seus amigos e conhecidos, no youtube este vídeo já foi visto 228 vezes e gostou 17 espectadores. Boa visualização!