I have tables Building and Address, where each Building is associated with 0..n Addresses.
I'd like to list Buildings with an associated Address. If a Building has several entrances, and thus several Addresses, I don't care which one is displayed. If a Building has no known addresses, the address fields should be null.
This is, I want something like a left join that joins each row at most once.
How can I express this in Oracle SQL?
PS: My query will include rather involved restrictions on both tables. Therefore, I'd like to avoid repeating those restrictions in the query text.