# ORA-01427 single-row subquery returns more than one row

**URL:** <https://forums.toadworld.com/t/ora-01427-single-row-subquery-returns-more-than-one-row/26324>\
**Category:** Toad for Oracle & DevOps Toolkit\
**Created:** [August 16, 2013, 8:49am UTC](https://forums.toadworld.com/t/ora-01427-single-row-subquery-returns-more-than-one-row/26324 "2013-08-16T08:49:20Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![ebay\_inc](https://avatars.discourse-cdn.com/v4/letter/e/e495f1/32.png) [@ebay\_inc](https://forums.toadworld.com/u/ebay_inc)\
**Post date:** [August 16, 2013, 8:49am UTC](https://forums.toadworld.com/t/ora-01427-single-row-subquery-returns-more-than-one-row/26324/1 "2013-08-16T08:49:20Z")

</div>

Hello All

Have select statement that I can’t get to run.

I have a data table and reference table

Issue is that my reference table is updated 4x times day along with my data table with it being the same look up data.

When i join on the reference table its inflating my numbers.

Wondering how i can join on my reference table and have a distinct join

a.SERVICE\_ID,  
count ( a.Dialout) as “Dials”,  
count ( a.DISP\_ID) as"Connects",  
sum (c.CONTACT) as “Contacts”

FROM call\_data a

JOIN reference\_table c

ON a.DISP\_ID = (select distinct c.DISP\_ID  
from reference\_table c  
where UPD\_DATE = (select max (UPD\_DATE)  
from reference\_table))

group by  
a.SERVICE\_ID  
order by  
a.SERVICE\_ID

Thanks

---

<div class="post-metadata">

**Author:** ![jpdominator](https://avatars.discourse-cdn.com/v4/letter/j/9fc29f/32.png) [@jpdominator](https://forums.toadworld.com/u/jpdominator)\
**Post date:** [August 16, 2013, 10:23am UTC](https://forums.toadworld.com/t/ora-01427-single-row-subquery-returns-more-than-one-row/26324/2 "2013-08-16T10:23:17Z")

</div>

I think you meant to do something like this.

```auto
 select a.service_id, a.disp_id, a.dials, a.connects, a.contacts, c.upd_date
from
(select SERVICE_ID,
disp_id,
COUNT(Dialout) AS Dials,
COUNT(DISP_ID) AS Connects,
SUM(CONTACT) AS Contacts
FROM call_data
group by SERVICE_ID, disp_id) a
JOIN (select disp_id, max(upd_date) upd_date
from reference_table
group by disp_id) c on a.disp_id = c.disp_id
order by a.service_id;

```

---

<div class="post-metadata">

**Author:** ![yodeporahi](https://avatars.discourse-cdn.com/v4/letter/y/85f322/32.png) [@yodeporahi](https://forums.toadworld.com/u/yodeporahi)\
**Post date:** [March 9, 2015, 12:33pm UTC](https://forums.toadworld.com/t/ora-01427-single-row-subquery-returns-more-than-one-row/26324/3 "2015-03-09T12:33:49Z")

</div>

I have the same issue with my querie:

SELECT

COALESCE(E.EMPLCODE,E.EMPLCODE) EMPLCODE,

COALESCE(E.FIRST\_NAME,E.FIRST\_NAME) FIRST\_NAME,

COALESCE(E.NAME\_INITIAL,E.NAME\_INITIAL) NAME\_INITIAL,

COALESCE(E.LAST\_NAME1,E.LAST\_NAME1) LAST\_NAME1,

COALESCE(E.LAST\_NAME2,E.LAST\_NAME2) LAST\_NAME2,

(SELECT D2.DESCRIPTION

FROM hrsense1.PADIV1 D2

LEFT JOIN hrsense1.PAEMP1 E2 ON E2.DIV1 = D2.DIV1

LEFT JOIN HRSENSE1.SSCODE S2 ON E2.COST\_CENTER = S2.CODE

WHERE S2.TYPE = ‘LAB’ ) LAB\_DESCRIPTION,

COALESCE(E.DIV1,E.DIV1) BUSINESS\_LEVEL\_1,

COALESCE(D.DESCRIPTION, null) BUSINESS\_LEVEL\_1\_DESCRIPTION,

COALESCE(E.COST\_CENTER,E.COST\_CENTER) COST\_CENTER,

COALESCE(S.DESCRIPTION, null) DESCRIPTION,

COALESCE(E.POSITION, null) POSITION,

COALESCE(P.DESCRIPTION, null) POSITION\_DESCRIPTION,

COALESCE(E.ACTUAL\_SALARY\_HOURS, E.ACTUAL\_SALARY\_HOURS) ACTUAL\_SALARY\_HOURS,

COALESCE(E.HIRE\_DATE, E.HIRE\_DATE) HIRE\_DATE,

COALESCE(E.STATUS, E.STATUS) STATUS,

COALESCE(PA.RATE, NULL) RATE,

coalesce(e.DEFAULT\_WORKS\_HRS\_PERIOD, null)DEFAULT\_WORKS\_HRS\_PERIOD

FROM HRSENSE1.PAEMP1 E

LEFT JOIN hrsense1.PADIV1 D ON E.DIV1 = D.DIV1

LEFT JOIN HRSENSE1.PAPOSI P ON E.POSITION = P.POSITION

LEFT JOIN HRSENSE1.SSCODE S ON E.COST\_CENTER = S.CODE

LEFT JOIN HRSENSE1.patram PA ON E.EMPLCODE = PA.EMPLCODE

where s.type = ‘COS’ AND E.EMPLCODE = ‘H0919918268’;
