SQLTeam.com | Weblogs | Forums

I want to display these rows but only display 2 column values if is_primary-mo = 1

I do not know how to display the data from f. i want to display the is_primary-mo, and f.street_address1, only if is_primary_mo = '1' but i don't want it in the where = '1' because that wil remove many of the rows. not every staff has this checked is_primary_mo.

Select a.last_name, a.first_name, a.id_number, a.start_date as 'Hire Date', e.program_name, a.dob, a.mobile_phone as Cell_phone, a.email_staff,
c.description as Role, f.is_primary_mo as 'Primary office', f.street_address_1

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

inner join staff_office_demographics_byprimary_view f
on a.staff_id=f.staff_id

Where a.end_date is null
order by a.last_name, a.first_name

The data currently is this: these are 2 rows. We want to show only the 1 and 27 17th Avenue but we want the rest of the columns to show in the first row, we just don't want the 0 and the 26 17th Dr

ABDULA-BOL SHATO 00472299 1753-01-01 00:00:00.000 AEN 1753-01-01 00:00:00.000 NULL SA@AAA.org Licensed Clinician 0 26 17th Dr

ABDULA-BOL SHATO 00472299 1753-01-01 00:00:00.000 AEN 1753-01-01 00:00:00.000 NULL SA@AAA.org Licensed Clinician 1 27 17TH AVENUE

We don't have any of your data or table structures, so it's almost impossible to help. Please provide usable DDL, sample data and expected results. Please don't post pictures as they don't help us recreate your scenario

is_primary-mo, and f.street_address1, only if is_primary_mo = '1'

case when 
    is_primary_mo = '1'
then 
    is_primary-mo
else 
    ''
end 
    as
       is_primary-mo
,

case when 
    is_primary_mo = '1'
then 
   street_address1
else 
    ''
end 
    as 
        street_address1
1 Like