Skip to content
Advertisement

how would I limit the results to only one address based on a preference

Some of the donor ID’s have multiple mailing addresses, and I just need to select only the first one for each donor, and if there is no mailing address tied to a donor ID, then I need to pull a billing address, and if no billing address, then shipping address. but only show one address

Advertisement

Answer

You could do something like this. Note the outer join – to make sure donors that don’t have an address are still shown in the result set (with null address columns). If this is not desired, change the join to inner join.

DATA FOR TESTING

QUERY AND RESULT

User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement