SELECT [EmpId], [EmpName],[Designation]
FROM [Emp]
GROUP BY
[EmpId],[EmpName],[Designation]
HAVING COUNT(*) > 1;
DELETE DuplicateRecord
FROM
(
SELECT * ,
DupRank = ROW_NUMBER() OVER (
PARTITION BY [KeyField]
ORDER BY (SELECT NULL)
)
FROM [YourTable]
) AS DuplicateRecord
WHERE DupRank > 1
WITH DuplicateRecord([firstname], [lastname],[country], duplicatecount)
AS (SELECT [EmpId], [EmpName], [Designation]
ROW_NUMBER() OVER(PARTITION BY [EmpId], [EmpName], [Designation] ORDER BY EmpId) AS DuplicateCount
FROM [emp])
DELETE FROM DuplicateRecord
WHERE DuplicateCount > 1;
Join Allow us to combine mutltiple tables based on relationships and return desiger results.
We will use two table as bellow for example.
EmpId | Name | managerid |
---|---|---|
1 | Vikash | |
2 | Nilesh | 1 |
3 | Prabhat | 1 |
TranId | EmpId | Month | Salary |
---|---|---|---|
1 | 1 | Jan-2024 | 5000 |
2 | 3 | Jan-2024 | 4000 |
3 | 4 | Jan-2024 | 3000 |
EmpId | Name | Month | Salary |
---|---|---|---|
1 | Vikash | Jan-2024 | 5000.00 |
3 | Prabhat | Jan-2024 | 4000.00 |
EmpId | Name | Month | Salary |
---|---|---|---|
1 | Vikash | Jan-2024 | 5000.00 |
2 | Nilesh | NULL | NULL |
3 | Prabhat | Jan-2024 | 4000.00 |
EmpId | Name | Month | Salary |
---|---|---|---|
1 | Vikash | Jan-2024 | 5000.00 |
3 | Prabhat | Jan-2024 | 4000.00 |
NULL | NULL | Jan-2024 | 3000.00 |
EmpId | Name | Month | Salary |
---|---|---|---|
1 | Vikash | Jan-2024 | 5000.00 |
2 | Nilesh | NULL | NULL |
3 | Prabhat | Jan-2024 | 4000.00 |
NULL | NULL | Jan-2024 | 3000.00 |
EmpId | Name | Manager |
---|---|---|
2 | Nilesh | Vikash |
3 | Prabhat | Vikash |
EmpId
|
Name |
Month |
Salary |
1 |
Vikash
|
Jan-24 |
5000 |
1 |
Vikash
|
Jan-24 |
4000 |
1 |
Vikash
|
Jan-24 |
3000 |
1 |
Vikash
|
Jan-24 |
5000 |
1 |
Vikash
|
Jan-24 |
4000 |
1 |
Vikash
|
Jan-24 |
3000 |
1 |
Vikash
|
Jan-24 |
5000 |
1 |
Vikash
|
Jan-24 |
4000 |
1 |
Vikash
|
Jan-24 |
3000 |
2 |
Nilesh
|
Jan-24 |
5000 |
2 |
Nilesh
|
Jan-24 |
4000 |
2 |
Nilesh
|
Jan-24 |
3000 |
2 |
Nilesh
|
Jan-24 |
5000 |
2 |
Nilesh
|
Jan-24 |
4000 |
2 |
Nilesh
|
Jan-24 |
3000 |
2 |
Nilesh
|
Jan-24 |
5000 |
2 |
Nilesh
|
Jan-24 |
4000 |
2 |
Nilesh
|
Jan-24 |
3000 |
3 |
Prabhat
|
Jan-24 |
5000 |
3 |
Prabhat
|
Jan-24 |
4000 |
3 |
Prabhat
|
Jan-24 |
3000 |
3 |
Prabhat
|
Jan-24 |
5000 |
3 |
Prabhat
|
Jan-24 |
4000 |
3 |
Prabhat
|
Jan-24 |
3000 |
3 |
Prabhat
|
Jan-24 |
5000 |
3 |
Prabhat
|
Jan-24 |
4000 |
3 |
Prabhat
|
Jan-24 |
3000 |
Marvellous Coder. All Rights Reserved.