Thursday, February 22, 2024

SQL - Data Cleaning Techniques | How to remove duplicates records

In this tutorial, you will learn "How to remove duplicates records " in SQL as a part of Data Cleaning techniques.
Data cleaning is an essential part of the data preprocessing pipeline to ensure that the data used for analysis or modeling is accurate, consistent, and reliable.

Removing duplicates: Duplicates in a dataset can skew analysis results. You can remove duplicates using the DISTINCT keyword or by using the GROUP BY clause.

DISTINCT: πŸ’ŽThe DISTINCT keyword is used to remove duplicate rows from the result set. πŸ’Ž It returns unique values in the specified column or combination of columns. πŸ’Ž DISTINCT applies to the entire result set and eliminates duplicate rows based on the selected columns. πŸ’Ž It's typically used when you want to retrieve unique values from one or more columns in a table.SELECT Distinct [EmpId] ,[EmpName] ,[Designation] ,[ManagerID] ,[ManagerName] FROM [dbo].[tblEmployee]
GROUP BY: πŸ’Ž The GROUP BY clause is used to group rows that have the same values into summary rows, typically for aggregation purposes. πŸ’Ž It divides the rows into groups based on the specified column or expression. πŸ’Ž GROUP BY is used with aggregate functions like COUNT, SUM, AVG, etc., to perform calculations on each group. πŸ’Ž It's often used when you want to calculate summary statistics or aggregate data based on certain criteria.
SELECT [EmpId] ,[EmpName] ,[Designation] ,[ManagerID] ,[ManagerName] FROM [dbo].[tblEmployee] group by [EmpId] ,[EmpName] ,[Designation] ,[ManagerID] ,[ManagerName]
Differences: πŸ’ŽUse DISTINCT when you want to retrieve unique values from one or more columns in a table. πŸ’ŽUse GROUP BY when you want to group rows based on certain criteria and perform aggregate calculations on each group.


To learn more, please follow us - πŸ”Š http://www.sql-datatools.com To Learn more, please visit our YouTube channel at — πŸ”Š http://www.youtube.com/c/Sql-datatools To Learn more, please visit our Instagram account at - πŸ”Š https://www.instagram.com/asp.mukesh/ To Learn more, please visit our twitter account at -
πŸ”Š https://twitter.com/macxima

No comments:

Post a Comment