| Yuranikspb |
|---|
| номер 2 интересует |
select a.id_film,
max(case when a.type=1 then a.id_peoples end) as актеры,
max(case when a.type=2 then a.id_peoples end) as продюсеры
from
(select fp1.id_film, fp1.id_peoples, fp1.type,
(select count(*) from films_peoples fp2 where fp2.type=fp1.type and fp2.id_film=fp1.id_film and fp2.id_peoples<=fp1.id_peoples) as num
from films_peoples fp1)a
group by a.id_film, a.num
и потом доджойниваеш таблицы films и peoples (последнюю - 2-ажды)