The MS SQL Server DISTINCT catchphrase is utilized related to SELECT explanation to dispense with all the copy records and getting just interesting records.
There might be a circumstance when you have different copy records in a table. While bringing such records, it bodes well to get just extraordinary records as opposed to getting copy records.
Syntax
Following is the essential language structure of DISTINCT watchword to kill copy records.
SELECT DISTINCT column1, column2,.....columnN
FROM table_name
WHERE [condition]
Example
Consider the CUSTOMERS table having the accompanying records.
ID NAME AGE ADDRESS SALARY
1 Ramesh 32 Ahmedabad 2000.00
2 Khilan 25 Delhi 1500.00
3 kaushik 23 Kota 2000.00
4 Chaitali 25 Mumbai 6500.00
5 Hardik 27 Bhopal 8500.00
6 Komal 22 MP 4500.00
7 Muffy 24 Indore 10000.00
Allow us to perceive how the accompanying SELECT question returns copy pay records.
SELECT SALARY FROM CUSTOMERS
ORDER BY SALARY
The above order will deliver the accompanying yield where compensation 2000 comes twice which is a copy record from the first table.
SALARY
1500.00
2000.00
2000.00
4500.00
6500.00
8500.00
10000.00
Allow us presently to utilize DISTINCT watchword with the above SELECT inquiry and see the outcome.
SELECT DISTINCT SALARY FROM CUSTOMERS
ORDER BY SALARY
The above order creates the accompanying yield where we don't have any copy passage.
SALARY
1500.00
2000.00
4500.00
6500.00
8500.00
10000.00