select stdcode,name,degree_code,phone,startsemester,endsemester
from (
select distinct stdcode as stdcode,name as name,degree_code as degree_code,phone as phone,
(
SELECT sem_code
FROM V_ALLSTUDATA b
WHERE a.name = b.name
and a.stdcode= b.stdcode
and a.degree_code=b.degree_code
and a.phone=b.phone
AND startsem=(select min(startsem)
from V_ALLSTUDATA b)
) as startsemester,
(
SELECT sem_code
FROM V_ALLSTUDATA b
WHERE a.name = b.name
and a.stdcode= b.stdcode
and a.degree_code=b.degree_code
and a.phone=b.phone
AND startsem=(select
max(startsem) from V_ALLSTUDATA a)
) as endsemester
from V_ALLSTUDATA a
);
I want to select sem_code
as startsem_code
and sem_code
as lastsem_code
How can I fix this error?
ORA-01427: single-row subquery returns more than one row
01427. 00000 - "single-row subquery returns more than one row"
*Cause:
*Action:
Because the subqueries have an explicit requirement that they match
min(startsem)
ormax(startsem)
, I believe that the subqueries will return only one value. However, they may return multiple instances of the same value.To protect against that, I think you want to add
distinct
to both subqueries, like this:you got multiple rows in the single query so I think you will be use rownum. so Try Below Query
Problem is in one (or both)
SELECT
statements that returnstartsemester
andendsemester
values. For example:It must not return more than a single value. As we don't have your data, we can't answer why you got
too_many_rows
. There are a few ways out, e.g.MAX
, e.g.select max(sem_code) from ...
distinct
helps, e.g.select distinct sem_code from ...
rownum
into thewhere
clause, e.g.... and rownum = 1
but - from my point of view - you should research what causes the error and fix it appropriately. Perhaps you missed some more conditions in the
where
clause; who knows? We don't, you might.this is what i was want .......> THIS IS CORRECT ANSWER
enter image description here