Amazon SQL Interview Question | Consecutive Number in SQL (With Self Join) | | Deepankar Pathak

Поделиться
HTML-код
  • Опубликовано: 18 ноя 2024

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

  • @theinsightminer08
    @theinsightminer08 Месяц назад

    Great ques, i first solved then i watched your solution , so this is a great way to practice.

    • @deepankarpathak983
      @deepankarpathak983  Месяц назад +1

      Thanks, I am going to solve this question with the help of windows function too. In the upcoming session stay tune👍

    • @theinsightminer08
      @theinsightminer08 Месяц назад +1

      @@deepankarpathak983 sure waiting

  • @16_nidhi40
    @16_nidhi40 Месяц назад

    thanks please keep posting

  • @Soul-f3v
    @Soul-f3v Месяц назад +1

    with cte as(
    select id,num,LEAD(num) over(order by id)as nxt_num from Series),
    nxt_nxt as(
    select id,num,nxt_num,LEAD(nxt_num) over (order by id) as nxt_nxt from cte)
    select distinct num from nxt_nxt where num = nxt_num and nxt_num=nxt_nxt;

  • @ishanshubham8355
    @ishanshubham8355 Месяц назад +1

    with cte as
    (
    select
    cast(id as signed) as id,num,
    cast(row_number() over(order by num) as signed) rn from Series
    ),
    cte2 as
    (
    select *,
    abs(id - rn) as cnt
    from cte
    )
    select num
    from cte2
    group by num, cnt
    having count(*) > 2

  • @jnanapradhana3377
    @jnanapradhana3377 Месяц назад +1

    with cte as(
    select *,lag(num,1) over(order by id) as ld,
    lead(num,1) over(order by id) as led
    from Series)
    select distinct num from cte where num=ld or num=led
    With the help of Window function.

  • @saurabhagrawal5466
    @saurabhagrawal5466 Месяц назад +1

    10-Oct-2024