Skip to content

added solution for Week3#2

Open
PlotnikovAleksey wants to merge 3 commits into
nikb-de:mainfrom
PlotnikovAleksey:main
Open

added solution for Week3#2
PlotnikovAleksey wants to merge 3 commits into
nikb-de:mainfrom
PlotnikovAleksey:main

Conversation

@PlotnikovAleksey
Copy link
Copy Markdown

Выполнение домашнего задания для Week3

@@ -0,0 +1,8 @@
select a.title as album_name,
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Принято

@@ -0,0 +1,10 @@
select g.name as g_name,
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Принято

@@ -0,0 +1,12 @@
select e1.last_name || ' ' || e1.first_name as emp_full_name,
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Принято

@@ -0,0 +1,19 @@
with artists_id_and_count as
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Принято

@@ -0,0 +1,14 @@
select e.last_name || ' ' || e.first_name as empl_full_name,
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Подумайте, что будет, если сотрудники полные тезки

Comment thread Week3/solutions/hw2_task6.sql Outdated
on t.genre_id = g.genre_id
join media_type mt
on mt.media_type_id = t.media_type_id
where g.name = 'Metal'
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Запрос должен уметь обрабатывать ситуации, когда был добавлен новый жанр, например, Black Metal

Comment thread Week3/solutions/hw2_task7.sql Outdated
join genre g
on t.genre_id = g.genre_id
where company is not null
group by g.name, c.company, t.name
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Может ли быть ситуация, что у разных артистов будут выпущены треки с одинаковым названием?

Comment thread Week3/solutions/hw2_task8.sql Outdated
t1.track_id as track_id,
t1.track_name as track_name,
t1.purchases_of_track / t2.sum_per_genre * 100 as popularity,
row_number() over (order by t1.genre_name, t1.track_name) as num
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Здесь предполагается пронумерование в рамках каждого жанра или всей таблицы в целом?

)
select t4.album_title as album_name,
t4.genre_name as genre_name,
coalesce(t5.cnt, 0) as cnt
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Почему в ответе есть альбомы с 0 в количестве треков. Пример альбом Allegri: Miserere

Copy link
Copy Markdown
Author

@PlotnikovAleksey PlotnikovAleksey Mar 29, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Потому что cnt показывает сколько треков было куплено в альбоме, а в альбоме Allegri: Miserere и некоторых других ни одного трека не купили (нет ни одного invoice_line c track_id тех треков, которые есть в данных альбомах)

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Принято

else t7.media_cnt
end as media_cnt,
CASE
when (t8.mt_name is null) then 0
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Почему в ответе есть 0 с media_cnt ?
Пример такого альбома

select * 
  from track
where album_id in (
select album_id
  from album
 where artist_id in (
         select artist_id
         from artist where name = 'Gustav Mahler')
)```

Хотя тип медиа здесь явно определен

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Для 'Gustav Mahler' у меня 0 не выводится. 0 выводится для тех артистов, у которых нет ни одного альбома.

Вопрос по формулировке задания: "Для каждого альбома тип медиа определяется как наибольшая суммарный размер треков по жанру". Возможно, здесь допущена опечатка и тип медиа определяется как наибольший суммарный размер треков по типу медиа? Я так и сделал.

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Принято

@PlotnikovAleksey
Copy link
Copy Markdown
Author

Добавил исправления

@PlotnikovAleksey
Copy link
Copy Markdown
Author

Выполнение домашнего задание для Week4 (без 7 номера)

@PlotnikovAleksey
Copy link
Copy Markdown
Author

@bakanchevn

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants