Possible Duplicate:
Aggregate SQL Function to grab only the first from each group
Hello everyone,
Suppose I have a view with the following select statement like this one:
select app.[applicationid], apref.personid as backupdbaid
from application.VW_APPLICATION app
left join general.applicationpersonroleref apref
on (apref.applicationid = app.applicationid and apref.roleid = 3)
left join person.person secondary
Which will naturally return the applications with NULL backupdbaid when there is no backup dba in the connection table and N rows in case the application has N backup dbas.
The problem is: I need to acquire either null or one row of the connected DBAs. The returned row doesn't actually matter, as long as it is just one.
Which one is the best way to do it?
Thanks a lot for your help!