SQLTeam.com | Weblogs | Forums

Special effects in data needed

I have a query that is fine but there is a lot of repetitive data due to the number of programs the staff is in. I would like to at least not display repeating columns. It's a staff based query at this point. I beleive it would display best grouped by program.

Select a.last_name, a.first_name, a.id_number, e.program_name, a.dob, a.mobile_phone, a.email_staff,
c.description as Role
from staff_view a
inner join staff_worker_role_link b
on a.staff_id = b.staff_id
inner join worker_role c
on b.worker_role_id = c.worker_role_id
inner join staff_program_link d
on a.staff_id = d.staff_id
inner join program_info e
on d.program_info_id = e.program_info_id
Where a.end_date is null
order by a.last_name, a.first_name

Just do a SELECT DISTINCT and it will be fine.

could also be duplicates because of the number of roles the staff are in. Distinct would work if only one role, but what are you using this for? Why are you joining to all of the other tables?