История изменений
Исправление Psilocybe, (текущая версия) :
select c.id as company_id,c.name,t.turnover
from company c left join
(
select
company_id,
turnover,
row_number() over (partition by company_id order by year desc, quarter desc) rn
from company_turnover
) t
on c.id=t.company_id and t.rn=1
Исправление Psilocybe, :
select c.id as company_id,c.name,t.turnover
from company c left join
(
select
company_id,
turnover,
row_number() over (partition by company_id order by year desc, quarter desc) rn
from company_turnover t
) t
on c.id=t.company_id and t.rn=1
Исправление Psilocybe, :
select c.id as company_id,c.name,t.turnover
from company c left join
(
select
company_id,
turnover,
row_number() over (partition by company_id order by year desc, quarter desc) rn
from company_turnover t
) t
on c.id=c.company_id and rn=1
Исходная версия Psilocybe, :
select t.company_id,c.name,t.turnover
from company c left join
(
select
company_id,
turnover,
row_number() over (partition by company_id order by year desc, quarter desc) rn
from company_turnover t
) t
on c.id=c.company_id and rn=1