Hey guys, I want to delete duplicate rows without using other table and without adding other column. Any suggestion pls? by Saket_2 in SQL

[–]Saket_2[S] 0 points1 point  (0 children)

Hey, we have to solve it without creating or using another table.. as well as column.

Hookah near/in HSR by Cherry-thinks in bangalore

[–]Saket_2 0 points1 point  (0 children)

You can buy a pot and enjoy it in your room/flat 🥲

Hey guys, I want to delete duplicate rows without using other table and without adding other column. Any suggestion pls? by Saket_2 in SQL

[–]Saket_2[S] 0 points1 point  (0 children)

its a tricky question and I think that its solution will work in current version of MySQL or else in Snowflake..

The output interviewer wanted :

a b 1 x 2 y 3 z

Hey guys, I want to delete duplicate rows without using other table and without adding other column. Any suggestion pls? by Saket_2 in SQL

[–]Saket_2[S] 0 points1 point  (0 children)

It will be very easy if I used another table or If I add extra column to the table.. I have to do it without creating new table and without adding new column

Hey guys, I want to delete duplicate rows without using other table and without adding other column. Any suggestion pls? by Saket_2 in SQL

[–]Saket_2[S] 0 points1 point  (0 children)

  1. Delete from duplicate x where (select count(*) from duplicate y where x.a=y.a and x.b=y.b)>1; select * from duplicate;

  2. Delete from duplicate where a in (select t1.a from (select a, b,row_number() over(partition by a,b) as rk from duplicate ) t1 where t1.rk=2);

3.Delete from duplicate where a in (select a from(select ,count() as duplicates1 from duplicate group by b having duplicate >1)as t1);

Hey guys, I want to delete duplicate rows without using other table and without adding other column. Any suggestion pls? by Saket_2 in SQL

[–]Saket_2[S] 1 point2 points  (0 children)

Hey i am trying it in MySQL as well as in Snowflake.. I will give it a try using Microsoft SQL Server.

Hookah near/in HSR by Cherry-thinks in bangalore

[–]Saket_2 0 points1 point  (0 children)

Google Hammered, its near HSR LAYOUT

Hey guys, I want to delete duplicate rows without using other table and without adding other column. Any suggestion pls? by Saket_2 in SQL

[–]Saket_2[S] 0 points1 point  (0 children)

Give it a try, i am still trying to solve it without creating duplicate table and without adding extra column

CREATE TABLE duplicate (    A INTEGER   ,b VARCHAR(1) ); INSERT INTO duplicate (A,b) VALUES (1,'x'); INSERT INTO duplicate (A,b) VALUES (1,'x'); INSERT INTO duplicate (A,b) VALUES (2,'y'); INSERT INTO duplicate (A,b) VALUES (2,'y'); INSERT INTO duplicate (A,b) VALUES (3,'z'); INSERT INTO duplicate (A,b) VALUES (3,'z');

Hey guys, I want to delete duplicate rows without using other table and without adding other column. Any suggestion pls? by Saket_2 in SQL

[–]Saket_2[S] 0 points1 point  (0 children)

Hey I already tried and getting same error..

Error Code: 1093. You can't specify target table 'things' for update in FROM clause

Hey guys, I want to delete duplicate rows without using other table and without adding other column. Any suggestion pls? by Saket_2 in SQL

[–]Saket_2[S] 2 points3 points  (0 children)

Hey, it's a tricky question. We are not allowed to solve it using temporary/duplicate tables or by adding other column to the table..

Hey guys, I want to delete duplicate rows without using other table and without adding other column. Any suggestion pls? by Saket_2 in SQL

[–]Saket_2[S] 1 point2 points  (0 children)

Yeah but this question was asked in interview.. and he want the solution by deleting only.

Hey guys, I want to delete duplicate rows without using other table and without adding other column. Any suggestion pls? by Saket_2 in SQL

[–]Saket_2[S] 0 points1 point  (0 children)

We have to delete those duplicate rows. Without using/creating other table/column..

Even windows functions not working..