Is there a way to write a select statement so that it does the
following:
Selects all students with a preferred addresses. If a student does
not have a preferred address, then select the first address that the
student has listed in the database.
So far this is what I have:
SELECT DISTINCT
PERSON.PERSON_ID ,
PERSON.STREET1 ,
PERSON.STREET2 ,
PERSON.CITY ,
PERSON.STATE ,
PERSON.COUNTRY ,
PERSON.ZIP_CODE ,
FROM
PERSON_ADDRESS
WHERE
PERSON_ADDRESS.PREFERRED_STATUS = '1';
The script above only gives me students with preferred addresses. I
am looking to add something like this:
<select statement goes here>
WHERE
PERSON_ADDRESS.PREFERRED_STATUS = '1'
If PERSON_ADDRESS.PREFERRED_STATUS = '0' Then
---SELECT TOP
-----PERSON.PERSON_ID ,
-----PERSON.STREET1 ,
-----PERSON.STREET2 .....
---FROM
-----PERSON_ADDRESS
End If
My example is just a prototype. Any ideas if something like this can
be accomplished?
Marcus
******