Loading...
「ツール」は右上に移動しました。
利用したサーバー: wtserver2
2いいね 75回再生

Understanding SELECT DISTINCT postgresql SQL

Published on Jan 27,2024:
In this video, we will look at the SQL Distinct select statement:
Syntax format is : SELECT DISTINCT column1, column2, ...FROM table_name WHERE condition;

SELECT DISTINCT statement is used to retrieve unique values from a column or combination of columns from a table
Ensures that the result contains only unique rows for a specified column
column1, column2, .. Specified the columns you want to retrieve unique values from
Table_name: the table where the data is retrieved.
WHERE condition (optional) filtes where the data is retrieved




Examples:
Select * from orders;


SELECT DISTINCT customer_name
FROM orders;

SELECT DISTINCT product_name
FROM orders;

SELECT DISTINCT product_name, city
FROM orders;


DDL for the table and loading the data below:

CREATE TABLE orders (
order_id INT,
customer_name VARCHAR(50),
product_name VARCHAR(50),
city VARCHAR(50)
);

INSERT INTO orders (order_id, customer_name, product_name, city)
VALUES
(1, 'Alice', 'Laptop', 'New York'),
(2, 'Bob', 'Smartphone', 'Los Angeles'),
(3, 'Alice', 'Tablet', 'New York'),
(4, 'David', 'Laptop', 'Chicago'),
(5, 'Alice', 'Laptop', 'New York'),
(6, 'Bob', 'Smartphone', 'Los Angeles');





You can download the file from the location:
github.com/learn2excel/LearnPostgresql


SUBSCRIBE to learn more about Power BI,Power Query, Power Pivot, Excel,SQL Server and Python!!
   / @learnexcelrelentless  



Our Playists:
SQL Playlist :goo.gl/PS5Ep6
DAX PlayList : goo.gl/S4W41D
Power BI PlayList: goo.gl/dXxvnB
Power Query Playlist: goo.gl/5QS7P4
Getting Started with Power BI:goo.gl/GHakLZ
Getting Started with Python: goo.gl/n24P3w


ABOUT DAGDOO:
Website:
Home Page: www.dagdoo.org/
Power BI Tutorials: www.dagdoo.org/excel-learning/tutorial-power-bi-de…


Questions? Comments and SUGESTIONS? You will find me here:

Twitter: @dagdooe

Category: Science & Technology
License: Standard YouTube License

コメント