0

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. I am asking how to display the data in a column if the value = 1. and also if another column would be included in this rule. All the 2 columns from the f prefix.

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

  • Does this answer your question? [Get top 1 row of each group](https://stackoverflow.com/questions/6841605/get-top-1-row-of-each-group) You need to `ORDER BY is_primary DESC` – Charlieface Oct 28 '21 at 14:23
  • I want all rows. I just want to display the columns in 'f' if the is_primary-Mo = 1 – Speech4free Speech Oct 28 '21 at 14:38
  • so if i select based on the where clause = 1 i wont get all the 0 rows. – Speech4free Speech Oct 28 '21 at 14:47
  • Perhaps you should make your example clearer with proper sample data and expected output, [formatted as tables](https://meta.stackoverflow.com/questions/277716/how-can-i-create-a-table-in-a-post) – Charlieface Oct 28 '21 at 14:50
  • I dont understand what is not clear. I want to only show the 2 columns f. is the value of the is_primary-mo = 1 but i want to include all the other rows where it is not = 1 – Speech4free Speech Oct 28 '21 at 15:43
  • You say *"all rows"* then you say *"I want to only show the 2 columns f. is the value of the is_primary-mo = 1 but i want to include all the other rows where it is not = 1 "* which seems contradictory. Please [edit] your question and show sample data and expected output – Charlieface Oct 28 '21 at 19:29

0 Answers0