Spotify SQL Interview Question | Advanced SQL

Поділитися
Вставка
  • Опубліковано 5 лис 2024

КОМЕНТАРІ • 17

  • @BHARATHEEYUDU.
    @BHARATHEEYUDU. 14 днів тому

    First kudos to you as you doing great job
    Can we achive this task without dense rank

  • @hairavyadav6579
    @hairavyadav6579 Місяць тому +3

    if someone inserting value may you get error for the column rank because it is function , so if we want to use rank as a column name use this
    `rank` then you can able to insert value in rank column ... ` this symbol is above the tab key in keyboard

  • @002anbarasisanthosh9
    @002anbarasisanthosh9 23 дні тому +1

    select a.artist_name
    , dense_rank() over( order by count(g.song_id) desc) as Rank_of_artist from artists a
    cross apply (select * from songs where artist_id =a.artist_id) s
    cross apply ( select * from global_song_rank where song_id =s.song_id and rank

  • @hairavyadav6579
    @hairavyadav6579 Місяць тому

    My approach
    with cte as (select a.artist_name as name,s.song_id from artists as a join songs as s on a.artist_id = s.artist_id),
    cte2 as(select c.name,count(*) as number_of_time from cte as c join global_song_rank as gr on c.song_id = gr.song_id where gr.rank

  • @HARSHRAJ-gp6ve
    @HARSHRAJ-gp6ve Місяць тому +1

    with cte as(
    select artist_name,song_id FROM artists JOIN songs ON artists.artist_id=songs.artist_id
    ),cte1 as(
    select cte.*,rank1 from cte JOIN global_song_rank ON cte.song_id=global_song_rank.song_id
    ),cte2 as(
    select artist_name,COUNT(*) as x1 FROM cte1 where rank1

  • @VikasChavan-v1c
    @VikasChavan-v1c 16 днів тому

    select a.artist_name,count(*),dense_rank() over (order by count(*) desc) as ranking from global_song_rank r join songs s on r.song_id=s.song_id join artists a on a.artist_id=s.artist_id
    where r.rnk

  • @Naliyadav
    @Naliyadav Місяць тому +1

    With CTE AS
    (
    select A.Artist_Id,A.Artist_name ,
    CounT(rank) As cnt
    from Artists A
    join Songs S
    on S.artist_id=A.Artist_id
    join global_song_rank G
    on G.Song_Id=S.Song_Id
    where g.rank

  • @pratyushkumar8567
    @pratyushkumar8567 Місяць тому

    with cte as(
    select artist_name ,g.song_id,g.rank,count(g.song_id) over(partition by artist_name) as cnt_
    from artists as a join songs as s on a.artist_id=s.artist_id
    join global_song_rank as g on s.song_id=g.song_id
    where rank

  • @prajju8114
    @prajju8114 Місяць тому

    with cte_songs as
    (
    select s.song_id,a.artist_id,a.artist_name,a.label_owner,s.name,g.day,g.rank from songs as s join artists as a on s.artist_id=a.artist_id join global_song_rank as g on s.song_id=g.song_id
    ),
    cte_2 as
    (
    select artist_name, count(song_id) as artist_count from cte_songs group by artist_name
    )
    select artist_name,dense_rank() over(order by artist_count desc) as 'rank' from cte_2

  • @Savenature635
    @Savenature635 Місяць тому

    with cte as (select distinct a.artist_name,s.artist_id,count(g.song_id) as number_of_appearances
    from artists a
    join songs s
    on a.artist_id=s.artist_id
    join global_song_rank g
    on s.song_id=g.song_id
    where g.rankk

  • @himanshubasra4451
    @himanshubasra4451 День тому

    select artist_name, dense_rank() over(order by sum(total_appearnce) desc) as artist_rank
    from
    (
    select s.*, a.artist_name, count(g.song_id) as total_appearnce
    from songs as s
    join artists as a on s.artist_id = a.artist_id
    left join global_song_rank as g on s.song_id = g.song_id
    group by s.song_id, a.artist_name
    )
    group by 1

  • @chaitanyagupta9767
    @chaitanyagupta9767 25 днів тому

    SELECT Top 5 A.artist_name, DENSE_RANK() OVER (order by count(*) desc) AS artist_rank FROM (SELECT a.*,s.name, gr.*FROM (SELECT * FROM artists) AS A left join (Select * from songs) as S
    ON A.artist_id = S.artist_id LEFT JOIN (SELECT * FROM global_song_rank) AS gr ON
    S.song_id=gr.song_id WHERE gr.song_id IS NOT NULL and gr.rank

  • @saikatmazumder206
    @saikatmazumder206 Місяць тому

    with cte as (select a.artist_id,a.artist_name,s.song_id,s.name,g.day,g.rnk from artists as a
    join songs as s on a.artist_id=s.artist_id join global_song_rank as g on s.song_id=g.song_id)
    select artist_name,dense_rank()over(order by count(rnk)desc) as artist_rank
    from cte group by 1 having count(rnk)

    • @prajju8114
      @prajju8114 Місяць тому

      query is incorrect, with cte as
      (
      select a.artist_id,a.artist_name,s.song_id,s.name,g.day,g.rank as rnk from artists as a
      join songs as s on a.artist_id=s.artist_id join global_song_rank as g on s.song_id=g.song_id
      )
      select artist_name,dense_rank()over(order by count(rnk) desc) as artist_rank
      from cte group by artist_name having count(rnk)

  • @rohit_vora
    @rohit_vora Місяць тому

    with cte as
    (select artist_name, count(1) cnt
    from
    (select artist_name, s.song_id , a.artist_id, rank from artists a
    join songs s on s.artist_id = a.artist_id
    join global_song_rank gr on gr.song_id = s.song_id
    where rank