Can't get this query to work in SQL (Oracle) -
im trying return officials name, hotel manage , number of matches have refereed below database (see relational diagram below).
i have tried following, doesn't work:
select officials.name official, hotels.name hotel, -- hotel official manages count (case when officials.name = matches.referee 1 else null end) matchesrefereed officials left join hotels on officials.staffid = hotels.manager left join matches on officials.staffid = matches.referee (case when hotels.name null '-' else hotels.name end); -- print '-' if not manage hotel i group function error select, , case statement @ end doesn't work.
relational diagram reference:

what dbms?
select officials.name official, nvl(hotels.name, '-') hotel, -- hotel official manages count (matches.referee) matchesrefereed officials left join hotels on officials.staffid = hotels.manager left join matches on officials.staffid = matches.referee group officials.name, nvl(hotels.name, '-')
Comments
Post a Comment