I have a script that ranks order contacts. 99.99% of the time, this results in a single top contact that I use to update a table.
But that one in 10k that has 2 contacts with the same ranking kills my script with the "single-row subquery returns more than one row" error .
Here's my query:
Is there way to make a sub-query just take the first row when there are multiple rows returned?
_________
Rott Paws
...It's not a bug. It's an undocumented feature!!!
But that one in 10k that has 2 contacts with the same ranking kills my script with the "single-row subquery returns more than one row" error .
Here's my query:
Code:
select
order_id,
contact_nm,
email_addr_txt,
contact_type_cd
from
completed_contacts cc
where
sc.pri=(select min(sc1.pri)
from completed_contacts cc1
where cc1.order_id=cc.order_id
group by cc1.order_id)
Is there way to make a sub-query just take the first row when there are multiple rows returned?
_________
Rott Paws
...It's not a bug. It's an undocumented feature!!!