My sample data with the Emp table
Emp
deptno eno
1 1
1 2
1 3
2 1
2 2
output:
deptno eno
1 3
2 2
out of this i need to have only one column in final output only
deptno
1
2
I am trying to write
select deptno from emp where deptno in (select deptno,max(eno)
from emp
group by deptno);
It is throwing error
I'm thinking . . .
select distinct deptno
from emp;
Does that meet your needs?
Try this
select deptno from emp where deptno in (
select deptno from emp where eno in (
select MAX(eno) from emp))
select deptno
from emp
group by deptno
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.