## Ebay Interview Question for Software Engineer / Developers

Comment hidden because of low score. Click to expand.
1
of 1 vote

the following is the perfect query ....

select
(select Sum(sal) from emp group by sal having sal=(select Max(sal)from emp)) -
(select Sum(sal) from emp group by sal having sal=(select Min(sal)from emp))
from dual;

Comment hidden because of low score. Click to expand.
-1
of 1 vote

Why do we need group by, how about

select
(select Sum(sal) from emp where sal=(select Max(sal)from emp)) -
(select Sum(sal) from emp where sal=(select Min(sal)from emp))
from dual;

Comment hidden because of low score. Click to expand.
0

nice !!!!!

Comment hidden because of low score. Click to expand.
0
of 0 vote

``select sum(sal) keep (dense_rank first order by sal asc) over (partition by dept) total_min_sal, sum(sal) keep (dense_rank last order by sal asc ) over (partition by dept)  total_max_sal,emp.* from emp``

Comment hidden because of low score. Click to expand.
0

select sum(sal) keep (dense_rank first order by sal asc) over (partition by dept) total_min_sal, sum(sal) keep (dense_rank last order by sal asc ) over (partition by dept) total_max_sal,emp.* from emp

Comment hidden because of low score. Click to expand.
0
of 0 vote

select max(s) - min(s) from ((select count(*)*value as s from salary group by (value) ) as t1)

Comment hidden because of low score. Click to expand.
0
of 0 vote

select m1 - m2 from (select sum(salary) as m1 from Surbhi where salary = (select max(salary)from Surbhi)) as t1,(select sum(salary)as m2 from Surbhi where salary = (select min(salary)from Surbhi)) as t2;

Comment hidden because of low score. Click to expand.
0
of 0 vote

select sum(salary)-(select sum(salary) from test where salary in (select min(salary) from test)) from test where salary in (select max(salary) from test);

The code works.. just tested it

Comment hidden because of low score. Click to expand.
0
of 0 vote

select sum(salary)-(select sum(salary) from test where salary in (select min(salary) from test)) from test where salary in (select max(salary) from test);

The code works.. just tested it.

Comment hidden because of low score. Click to expand.
0
of 0 vote

Thanks gullu!!!

Comment hidden because of low score. Click to expand.
0
of 0 vote

select e.salary, count(*), sum(e.salary)
from employee e
inner join
(select max(salary) max, min(salary) min from employee) t
where e.salary in (t.max, t.min)
group by e.salary

Comment hidden because of low score. Click to expand.
0
of 0 vote

select (select sum(salary) from employee where salary = (select max(salary) from employee)
- select sum(salary) from employee where salary = (select min(salary) from employee)) from dual;

Comment hidden because of low score. Click to expand.
0
of 0 vote

select sum(a.salary) - sum(b.salary) from emp a, emp b
where a.salary = (select max(salary) from emp)
and b.salary = (select min(salary) from emp);

Comment hidden because of low score. Click to expand.
-1
of 1 vote

select max(salary*count )-min(salary*count ) from( select salary, count(*) as count from employee group by salary)

Name:

Writing Code? Surround your code with {{{ and }}} to preserve whitespace.

### Books

is a comprehensive book on getting a job at a top tech company, while focuses on dev interviews and does this for PMs.

### Videos

CareerCup's interview videos give you a real-life look at technical interviews. In these unscripted videos, watch how other candidates handle tough questions and how the interviewer thinks about their performance.