"if you encounter any errors in SAP, send me a screenshot at pramod@learntosap.com, and I will help you resolve the issue."

SQL SELECT DISTINCT Statement Clause

SQL TUTORIALS-

SQL SELECT Query-Statement

Introduction-


Trulli Trulli

SQL SELECT DISTINCT Statement Clause-

SELECT DISTINCT clause is used to return only unique (different) values from a specified column or set of columns in a table... Follow this Statement Here's a basic overview...

✅Why Use DISTINCT?-

✅When you query a table, the result might include duplicate rows.

✅Using DISTINCT filters out duplicate rows so each row returned is unique.


✅ Basic Example:-


SELECT DISTINCT column1, column2, ...
FROM table_name;

✅column1, column2, ... — Columns from which you want unique combinations of values.

✅table_name — The table you are querying.

Result Show :-

Emoji Examples in HTML

Employees


EmployeeID Department
1 IT
2 HR
3 Sales
4 Production

✅ Example -SELECT DISTINCT Department:-

SELECT Query :-

SELECT DISTINCT Department
FROM Employees;

Result Show :-

Emoji Examples in HTML

Employees

Department
IT
HR
SALES
PRODUCTION

✅ Example -SELECT DISTINCT employee names:-

SELECT Query :-

SELECT DISTINCT Name FROM Employees;

Result Show :-

Emoji Examples in HTML

Employees

Name
Pramod
Pooja
Rajesh
Rupesh

✅ Example -SELECT DISTINCT with multiple columns where duplicates exist:-

SELECT Query :-

SELECT DISTINCT Name, Department FROM Employees;

✅ Example -SELECT DISTINCT job titles from an Employees table:-

SELECT Query :-

SELECT DISTINCT Name, Department FROM Employees;

✅Key Points-

✅-DISTINCT applies to all columns listed after SELECT.

✅-It returns unique combinations of values across those columns.


May Be Like Important Link-

-Chart Of Account-OB13

-Define Plant-OX1

-Chart Of Account-OB13

-Define Financial Statement