so I have made a select query like this:
select distinct
f.[film name]
,f.city
,case rt.[type name]
when 'director' then p.[participant name] else null end 'partecipant name'
,case rt.[type name]
when 'director' then 'director' else null end 'role type'
from Films f
inner join FilmParticipants fp on fp.filmID=f.filmID
inner join Participants p on p.participantID=fp.participantID
inner join RoleType rt on rt.roleID=fp.roleID
where f.city in(
select f.city
from Films f
group by f.city
having COUNT(*)>1
)
order by f.city
it yields this table:
film name | city | participant name | role type
__________________________________________________
Dragon | London | null | null
Dragon | London | Morty | director
Dragon | London | James | director
Shrek | London | null | null
now I want to eliminate the first row, since I dont need it, it has nulls and I have the film name in the second row. but I cant do 'where [participant name]=null...etc..' because it will also remove my third row, which I need since his name only shows once. what do I do? and I cant use the 'max' function because it will eliminate the third row also.
logic explanation: the cases made sure that whenever it is not a 'director' role it is null role, and so is the participant name column(if role column is not a 'director' it is null). as to what to show if there is only one row of that film name, I need it to be seen, even if it has nulls. but if there is more than one row of that film it should eliminate the null rows of it and show all of those that are not nulls