Retrieve unique records in SQL WITHOUT using distinct
Dataset:
Create table statement
Create table test
(
id int,
Name varchar(10)
)
Run the below commands more than once
Insert into test
VALUES
(1,'Rohit')
Insert into test
VALUES
(2,'Rahul')
Query with Distinct
Query without distinct
UNION always removes duplicates from the output. So, apply union to the same query so that it will return the unique records in the output
Detailed explanation: https://youtu.be/hcxogMdSRQA
Comments
Post a Comment