I'm porting mp3jukebox.
How should this view be ported?
Oracle:
create or replace view mp3_mp3_playlist_map_view as
select m.mp3_id,
m.playlist_id,
m.sort_key,
nvl(v.total,0) as total
from mp3_mp3_playlist_map m,
(select mp3_id,
playlist_id,
sum(vote) as total
from mp3_votes
group by mp3_id, playlist_id) v
where m.mp3_id = v.mp3_id (+)
and m.playlist_id = v.playlist_id (+);
My attempt in Posrgres:
create view mp3_mp3_playlist_map_view as
select m.mp3_id,
m.playlist_id,
m.sort_key,
coalesce(v.total,0) as total
from mp3_mp3_playlist_map m
left join (select mp3_id,
playlist_id,
sum(vote) as total
from mp3_votes
group by mp3_id, playlist_id) v
using (mp3_id)
left join v using (playlist_id);
I get:
ERROR: Relation 'v' does not exist