DELETE DUPLICATE ROWS FROM A TABLE IN SQL || 4 ways

  Рет қаралды 206,255

Crack Concepts

Crack Concepts

Күн бұрын

Пікірлер: 183
@crackconcepts
@crackconcepts Жыл бұрын
✨Link to my SQL e-book: imojo.in/rkajq9 ✨Link to 'Switch your career easily' e-book: imojo.in/1FL7KaG (Perfect for anyone willing to switch to a completely new field or to a different company in the Tech World)
@rajkiranboggala9722
@rajkiranboggala9722 4 жыл бұрын
I really appreciate your time and effort in sharing these (even though you are having cold)!! Thank you
@srinivasprasad7765
@srinivasprasad7765 3 жыл бұрын
Ya true..👍
@ravindrabisht7372
@ravindrabisht7372 3 жыл бұрын
That's called dedication...keep it up dear
@ShubhamKumar-mf4sg
@ShubhamKumar-mf4sg 2 жыл бұрын
Having cold ..hahaha..nailed it bro
@tubepankajyou
@tubepankajyou 2 жыл бұрын
Such developers actually reach to top positions, appreciate it.
@karthikd2104
@karthikd2104 3 жыл бұрын
Seen so many videos in SQL messed up ...this one really understandable with clear explanation!
@adapass
@adapass 2 жыл бұрын
explanation is very clear by writing in paper which is unique in youtube. great job
@marvinmachitar7229
@marvinmachitar7229 3 жыл бұрын
Wow! You are so good teacher. Was able to understand it more than other videos with fancy animation.
@tchelaa6894
@tchelaa6894 Жыл бұрын
I have been stuck on this since yesterday. Thank you😎
@MoodyVideoGraphies
@MoodyVideoGraphies 2 жыл бұрын
kitni awesome hai yaar... So well explained... calm and soothing...
@umaannamalai3205
@umaannamalai3205 4 жыл бұрын
Thank you for the clear explanations! You made the concepts simple to understand. I’m excited for new videos.
@akashagarwal6390
@akashagarwal6390 4 жыл бұрын
Mam it would be great if you can take up topics or concepts which are really important like this though not much frequently asked in interviews and also it is useful for an engineer to know all these as well
@rakeshgopidi4066
@rakeshgopidi4066 2 жыл бұрын
It's a great post Sadia, no matter how many years of experience we have ,it's always a good revision for any one # Additional Reference There are also other ways to restrict the duplicates 1. UNIQUE 2. UNION 3. ROW_NUMBER | RANK () | DENSE_RANK () - Analytical Function 4. INTERSECT 5. MINUS 6. ROWID | ROWID + CORRELATED SUBQUERY 7. GROUP BY
@mastanshaik5479
@mastanshaik5479 3 жыл бұрын
Nice & simple way of understanding 👏👏 for new starters in sql ur videos are best .. thank you for ur efforts and time
@giridandi7480
@giridandi7480 2 жыл бұрын
Very nice.simple understanding way you explain so nice
@naveenshagala3136
@naveenshagala3136 5 жыл бұрын
Nice explanation with such a calm voice.
@crackconcepts
@crackconcepts 5 жыл бұрын
Thank you 😃
@sushantpawar5635
@sushantpawar5635 3 жыл бұрын
शेंबडाचा त्रास होत असताना देखील खूप छान शिकवलंस🙏👍 thank you
@Rjjithin777
@Rjjithin777 3 жыл бұрын
Simply superb, doing a great job, simple and clear
@hidden590
@hidden590 4 жыл бұрын
First method is easy to understand ...so I will go with the first method
@FitVisionTV
@FitVisionTV 3 жыл бұрын
First method will overload database performance. Avoid using select *
@bhavanikandikondamatam5926
@bhavanikandikondamatam5926 3 жыл бұрын
Hello madam.. I have doubt in using temporary table.. Can insert distinct values in new table Drop the old table Rename new table as old table?
@saravananbhojan8750
@saravananbhojan8750 3 жыл бұрын
Learned best way to query thanks for the video !!
@rajattalnikar6167
@rajattalnikar6167 3 жыл бұрын
Thankyou so much. You've covered all the methods and discussed them in detail.
@zafariqbalunknown9786
@zafariqbalunknown9786 2 жыл бұрын
Your efforts helped me a lot Thankyou mam
@husler7424
@husler7424 2 жыл бұрын
Watching in 2022, for placements as being CSE student. Thanks a lot, didi. Your explanation is just amazing.
@rajendrarajendra583
@rajendrarajendra583 2 жыл бұрын
Your explanation is superb. one small request what ever you explained can you explain in sql server . that is very use full to us.
@deepakaggarwal8624
@deepakaggarwal8624 3 жыл бұрын
Excellent, your solutions are just great and easy to understand
@akashverma1640
@akashverma1640 3 жыл бұрын
Thank you very much for you efforts... Must to be known things👌👌
@DeepakMeena-kz9bu
@DeepakMeena-kz9bu 3 жыл бұрын
over partition example was really helpful
@ankiturmaliya7286
@ankiturmaliya7286 Жыл бұрын
very good explanation..
@maryamfatima5882
@maryamfatima5882 2 жыл бұрын
excellent explanation
@boddanapalliavinash6418
@boddanapalliavinash6418 2 жыл бұрын
Very good explanation keep it up 👍
@techninja9461
@techninja9461 3 жыл бұрын
Excellent Explanation.....This video is really helpful.
@aeriesx4727
@aeriesx4727 3 жыл бұрын
Absolutely brilliant explanation... Thank you so much..
@oic_Oracle_integration_cloud
@oic_Oracle_integration_cloud 2 жыл бұрын
SO SIMPLE AND EASY
@joshyjohn9636
@joshyjohn9636 3 жыл бұрын
Well explained, It will be most useful video in this topic..
@hadireg
@hadireg 3 жыл бұрын
a bit speedy but you're doing a great job!
@MUSKAN0896
@MUSKAN0896 2 жыл бұрын
This was very helpful! Thank you so much
@veerulinganagoudar3456
@veerulinganagoudar3456 2 жыл бұрын
It's really helpful
@ganeshstars1
@ganeshstars1 3 жыл бұрын
your explanation is good. I am watching most of the videios. for me 1 st method is showing error missing expression.
@nimmikcherian3242
@nimmikcherian3242 3 жыл бұрын
Very detailed description... thanks
@umeshgolla2730
@umeshgolla2730 5 жыл бұрын
Excellent explaination..
@crackconcepts
@crackconcepts 5 жыл бұрын
Thank you!
@meditationandrelaxationmus741
@meditationandrelaxationmus741 3 жыл бұрын
Thanks it is very important interview question
@nausheen292
@nausheen292 3 жыл бұрын
Very well explained....Thank you 😀
@shivyogi806
@shivyogi806 5 жыл бұрын
You have amazing, simple.way of teaching. God bless you and Thank you very much
@swapneelkambe2092
@swapneelkambe2092 2 жыл бұрын
Good explanation
@Sriramlivz
@Sriramlivz 4 жыл бұрын
Nice Explaination. You have a lovely voice
@rosonerri-faithful
@rosonerri-faithful 2 жыл бұрын
Can we use the MAX(ID) method?
@mohansaivelagapudi929
@mohansaivelagapudi929 2 жыл бұрын
Thanks for Helping
@leesubiramaniyam2704
@leesubiramaniyam2704 3 жыл бұрын
Explaining good & may be increase the volume (sound) better good
@mrf7283
@mrf7283 3 жыл бұрын
very good effort and I appreciate your clips. However I have a question; suppose application messed up and gave same ID to two (2) different unique valid name. eg. 5001 to ABC and 5001 to XYZ and we want to keep both that is they should exists in our resultant with 2 unique IDs. Please don't get me wrong I am not trying to trick you, I had this real situation once with thousands of rows and was stuck.
@MohanGonnabathula
@MohanGonnabathula Жыл бұрын
In that scenario, you need to add ID, name in partition. DELETE FROM ( SELECT *, ROW_NUMBER() OVER (PARTITION BY ID, NAME ORDER BY ID) AS Rno FROM emp ) AS E WHERE Rno > 1; This query will delete duplicate rows from the "emp" table where duplicates are determined by the combination of "ID" and "NAME" columns, keeping only the first occurrence and removing the rest.
@shwetabudake6144
@shwetabudake6144 3 жыл бұрын
Very well explained
@namratanikam7566
@namratanikam7566 3 жыл бұрын
Well explained👍
@azharuddinluhar9667
@azharuddinluhar9667 3 жыл бұрын
3rd and 4th way will delete duplicate row from result set and not from actual table, now what to do for deleting duplicate rows from actual actual?
@sohailkat8867
@sohailkat8867 3 жыл бұрын
Nice video, and it would be great if you could make a video on types of Analytical Functions in sql, thanks!
@richardconnolly4295
@richardconnolly4295 3 жыл бұрын
SUPER HELPFUL!
@jaganjayakumar4874
@jaganjayakumar4874 5 жыл бұрын
Clear explanation keep doing more videos👍
@praveenvadde278
@praveenvadde278 3 жыл бұрын
Good explanation. Can please explain and show by executing in the system.
@ravindrabisht7372
@ravindrabisht7372 3 жыл бұрын
Your English is good
@mudasar8629
@mudasar8629 3 жыл бұрын
Thank a lots !!! :) Hope to see more videos from you.
@shubhamchoudhary5461
@shubhamchoudhary5461 3 жыл бұрын
So informative...👍
@Aryan-ly5ho
@Aryan-ly5ho 4 жыл бұрын
Helped me a lot Thanks 😁
@shubhamanand1347
@shubhamanand1347 4 жыл бұрын
your videos are awesome please make more videos on different topics
@shankar8816
@shankar8816 3 жыл бұрын
Ek different positive way me le gye aap lecture ko.. Wldone
@sukritsen9530
@sukritsen9530 5 жыл бұрын
Hello, I have a question, how to delete duplicate records with no unique key in mysql? Can this be done using the row_number function?
@chanduch8973
@chanduch8973 4 жыл бұрын
DELETE K FROM (SELECT *, ROW_NUMBER () OVER (PARTITION BY emp_id ORDER BY emp_id) AS RN FROM MyTable) K WHERE RN>1
@ravaliannaldas9320
@ravaliannaldas9320 2 жыл бұрын
Nyc video sister.
@akash_pal
@akash_pal 4 жыл бұрын
well Explained !! Thank you.
@bro_7079
@bro_7079 4 жыл бұрын
kzbin.info/www/bejne/sHKcp2yio7VleKc
@tushardeepsingh4976
@tushardeepsingh4976 3 жыл бұрын
Hi..one question i have ..pls rply ASAP... I'm using MYSQL and MYSQL doesn't support select * into.. therefore i used insert into newtable select distinct * from old table ...here i faced one issue...i hv one tble with eid,ename and salary. eid field is PK and ename and salary has duplicate values ...now when i use insert into using distinct keyword it copies duplicate data as well ......i only want distict data to be copied ..i tried dropping PK but on column eid but i'm facing same issue
@tushardeepsingh4976
@tushardeepsingh4976 3 жыл бұрын
Hii.. Please clear one question in this video ..In CTE inner query ..you have not used * after select keyword ..you have directly written " select row_number()..." .... * aaega na after select ??
@maxiejane
@maxiejane 4 жыл бұрын
So helpful thank you for sharing!
@AmanKhan-ei4cg
@AmanKhan-ei4cg 4 жыл бұрын
Thanks for such stuff🥰
@helmiboubaker2742
@helmiboubaker2742 3 жыл бұрын
sorry but the third ways not working for me . this the query that i use delete from (select nom, row_number() over(partition by nom order by nom ) as count_num from fourniseurs)as tab where count_num >1; but the select query work fine i wander why is it not working i use workbench mysql :/
@mobileminimaster3015
@mobileminimaster3015 3 жыл бұрын
delete from fourniseurs where nom IN (select nom from (select nom,row_number() over(partition by nom) as count_num from fourniseurs) ee where ee.count_num>1 );
@vrcks8066
@vrcks8066 3 жыл бұрын
ur voice is so nice😍
@yes-pg5dy
@yes-pg5dy 3 жыл бұрын
Excellent madam pls do videos on power bi also pls
@dreambig1668
@dreambig1668 4 жыл бұрын
Hi just one suggestion you first way will always not would the solution for routine. N in your second way we have to design table with identify type then you will be able to access
@norbycreation1851
@norbycreation1851 2 жыл бұрын
INSERT INTO temp_table SELECT DISTINCT * FROM old_table;
@saurabhbenbanshi3460
@saurabhbenbanshi3460 4 жыл бұрын
thanks you explained well...
@YPTechDATIA
@YPTechDATIA 4 жыл бұрын
use insert into newtable select distinct * from oldtable; then delete * from oldtable; now insert into oldtable select * from newtable;
@mannu567
@mannu567 Жыл бұрын
Instead of MIN if we use Max then what will happen? I guess it will also remove duplicate
@labheshlalka9666
@labheshlalka9666 3 жыл бұрын
Why we can't use direct delete query whose count greater than 1
@vivekrahate2564
@vivekrahate2564 2 жыл бұрын
Thank u dear..
@CarlosRivera-mp7mm
@CarlosRivera-mp7mm 2 жыл бұрын
Excelente muchas gracias
@alekhyabodapati5003
@alekhyabodapati5003 3 жыл бұрын
where rn>1 is not a good practice use having rn> 1 instead of it. Good video
@sandysahu5651
@sandysahu5651 2 жыл бұрын
The row_number() methodology is not working in snowflake db . anyone help me on this, how to resolve this like if we have to mention some alias name aslo and instead of rn>1 if we have to write alias.rn>1
@mangamanasvi5485
@mangamanasvi5485 4 жыл бұрын
Good Job!, Thank you.
@kshathrugan5238
@kshathrugan5238 4 жыл бұрын
The first method ,the same query will it work in Oracle sql
@saisumanthnagasuri7741
@saisumanthnagasuri7741 2 жыл бұрын
What happen if there are more than 50 columns with the duplicate records Instead of passing all the columns names to the partition by clause Is there any way to put * . Any thoughts?
@aditiarjun519
@aditiarjun519 4 ай бұрын
Hello mam, deleting using CTE throws the following error.... "Error Code: 1288. The target table cte of the DELETE is not updatable" how to resolve it?
@mrrishiraj88
@mrrishiraj88 3 жыл бұрын
Great videos.
@arjunpawar4564
@arjunpawar4564 3 жыл бұрын
In third method : Can we access alias rn in outer query as well as use in where condition ?
@Pooja-pd1ee
@Pooja-pd1ee 3 жыл бұрын
It won't work.
@shubhamshingi4657
@shubhamshingi4657 3 жыл бұрын
Will 3rd and fourth approach delete row from original table or it will just delete from temp table/result sets ? can you please clear my doubt
@galymzhankenesbekov2924
@galymzhankenesbekov2924 3 жыл бұрын
i also had the same doubt, but decided to insert into temporary table first and then do operations in a temporary table instread of original DB
@octotube463
@octotube463 3 жыл бұрын
Both of them won’t impact the actual table. 4th method is just removing the duplicates from the temp table, you can achieve by using a distinct query 😂. My guess for the 3rd query is it will remove both the duplicate and the actual record.
@qaz_testzaq_test8138
@qaz_testzaq_test8138 3 жыл бұрын
Good work, thanks
@dstar2211
@dstar2211 5 жыл бұрын
superb...good job...
@crackconcepts
@crackconcepts 5 жыл бұрын
Thank you!
@88pianissimo90
@88pianissimo90 2 жыл бұрын
I think row_number( ) works slower ... right? If you have millions of records then this will work slow.
@digitalcode5685
@digitalcode5685 2 жыл бұрын
THANKS
@antojeanston4781
@antojeanston4781 5 жыл бұрын
it will be really helpful , if you do this on your system, please, it should be a live workout from your end, instead of explaining it on the written paper.
@priyakumar3802
@priyakumar3802 5 жыл бұрын
She will explain the way she wants to explain.You should be thanking her instead of showing flaws
@music4u1235
@music4u1235 2 жыл бұрын
so sNice tutorialt like that
@ramchinthakayala2092
@ramchinthakayala2092 4 жыл бұрын
How come only distinct values will stored in new table if use -- Insert into old_table select * from new _table ? pls explain
@yashgoswami5374
@yashgoswami5374 3 жыл бұрын
because than new table has distinct values
@rk-ej9ep
@rk-ej9ep 3 жыл бұрын
Very nice
@stoic2454
@stoic2454 3 жыл бұрын
any idea why a CTE is used when we can create temporary table using sub query.?
@octotube463
@octotube463 3 жыл бұрын
Again, changes in the CTe table wouldn’t impact the actual table. 3rd and 4th queries won’t work.
@sathyasathyam6930
@sathyasathyam6930 4 жыл бұрын
Super thank 🌹you
@HardikShah17
@HardikShah17 4 жыл бұрын
Perfect. Thanks.
@galymzhankenesbekov2924
@galymzhankenesbekov2924 3 жыл бұрын
also i did this DECLARE @employee TABLE (emp_id INT IDENTITY PRIMARY KEY, last_name VARCHAR(30) NOT NULL, first_name VARCHAR(30) NOT NULL, job_title VARCHAR(50) NOT NULL) INSERT INTO @employee VALUES ('Smith', 'James', 'Staff Accountant'), ('Smith', 'James', 'Staff Accountant'), ('Williams', 'Roberta', 'Sr. Software Engineer'), ('Weinberg', 'Jeff', 'Human Resource Manger'), ('Franklin', 'Victoria', 'Operations Manager'), ('Armstrong', 'Williams', 'Database Administrator'), ('Cromley', 'Eric', 'Recruting Manager'), ('Smith', 'James', 'Staff Accountant'), ('Richardson','John', 'Safety Clerk'), ('Horton', 'Michelle','Accounting Manager'), ('Washington','Mark', 'HelpDesk Technician') select * from @employee; with CTE as( select e.*, ROW_NUMBER() over (partition by emp_id order by emp_id) as rn from @employee e ) delete from CTE where rn >1 also did not work
@foolchandsonariwal4203
@foolchandsonariwal4203 2 жыл бұрын
Madam derived table delete allow nahi karta he only u can use cte to delete duplicate record.
HOW TO SOLVE QUERIES IN SQL IN INTERVIEWS | QUERY NO 2
5:12
Crack Concepts
Рет қаралды 20 М.
Delete Duplicate Rows from SQL Table using 3 ways
12:21
GetSet SQL
Рет қаралды 22 М.
To Brawl AND BEYOND!
00:51
Brawl Stars
Рет қаралды 16 МЛН
Интересно, какой он был в молодости
01:00
БЕЗУМНЫЙ СПОРТ
Рет қаралды 3,6 МЛН
UFC 310 : Рахмонов VS Мачадо Гэрри
05:00
Setanta Sports UFC
Рет қаралды 1,1 МЛН
А я думаю что за звук такой знакомый? 😂😂😂
00:15
Денис Кукояка
Рет қаралды 6 МЛН
SQL "difference between" interview questions (part 1)
8:20
Crack Concepts
Рет қаралды 632 М.
Oracle PL SQL interview question | SQL to Delete duplicate records
17:27
Part 1   How to find nth highest salary in sql
11:45
kudvenkat
Рет қаралды 1,9 МЛН
To Brawl AND BEYOND!
00:51
Brawl Stars
Рет қаралды 16 МЛН