AMAZON Interview Question | SQL Intermediate Question 9

Поделиться
HTML-код
  • Опубликовано: 12 дек 2023
  • QUESTION - Remove all the reversed pair from the given table.
    DDL Command :-
    drop table tb1;
    create table tb1(n int , m int);
    insert into tb1
    values(1,2),(2,3),(3,4),(2,1),(3,2),(5,6);
    select * from tb1;
    #amazon #netflix #google #microsoft #flipkart #sqldeveloper #dataanalytics #dataengineering #sqlserver #interviewquestions #ml #ai

Комментарии • 2

  • @zaravind4293
    @zaravind4293 7 месяцев назад

    Great work pls keep posted this type of interview questions

  • @ajaykrishnanj5633
    @ajaykrishnanj5633 3 месяца назад +1

    select * from (
    select *,ROW_NUMBER() over(partition by flagtab.concat order by n) as flag from (
    select *,
    case when n>m then CONCAT(n,m) else CONCAT(m,n) end as concat
    from tb1) as flagtab)as new where new.flag=1