lundi 29 novembre 2021

SQL Query If more than one contact I only want the first listed

I am trying to write a query that joins residents emergency contacts names and phone numbers however we have several types of emergency contacts they can list.

For example: they can list emergency contact, responsible party, Power of Attorney.

I am wanting to pull back Responsible party. But some have 2 responsible parties listed and some have none and only an emergency contact.

How do I get just the first listed Responsible party and or if they do not have a responsible party listed grab the emergency contact but only 1 not several if they list more than one emergency contact.

Resident Name   Contact Name    Phone          Contact Type
----------------------------------------------------------------
Jane Doe        John Smith      999-999-9999   Responsible Party
Jane Doe        Patrick Star    999-888-8888   Responsible Party

I only want one of those Responsible Party not both

Thanks for your help!

Aucun commentaire:

Enregistrer un commentaire