Nivio Technologies Interview Question for Testing / Quality Assurances






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

in mysql it can be done in simple way

select salary
from employee
order by salary
desc
limit 3,1

it will give 4th salary, if you want 6th salary then replace 3 by 5

- kaustubh deshmukh September 18, 2012 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

almost right.
you didn't consider the situation that many employees may have the salary at the fourth highest.

- icecreamlc January 23, 2013 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 votes

you didn't consider duplicate salary, if there are 4 people have same No.1 salary.

- amor89813 March 27, 2014 | Flag
Comment hidden because of low score. Click to expand.
1
of 1 vote

select name,salary
from employee
where sal in (SELECT TOP 1 salary
FROM (
SELECT DISTINCT TOP 4 salary
FROM employee
ORDER BY salary DESC) a
ORDER BY salary DESC)

- Ananya December 17, 2010 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

Should it not be like this

select name,salary
from employee
where sal in (SELECT TOP 1 salary
FROM (
SELECT DISTINCT TOP 4 salary
FROM employee
ORDER BY salary DESC) a
ORDER BY salary ASC)

- Dev January 28, 2011 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 votes

It should.

- eugene.yarovoi July 17, 2012 | Flag
Comment hidden because of low score. Click to expand.
1
of 1 vote

select name, salary
from employee t
where (select count(1) from employee t1 where t1.salary > t.salary) = 3;

- Anonymous December 19, 2010 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

hi there,

although your query is little heavy interms of performance, it yields correct results. Could you explain me your query when you gotta min..

- prash July 22, 2011 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 votes

This query is called correlated query in TSQL. Basically creates copy of your table and compares one by you.

- QualitySpreader October 11, 2013 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 vote

I guess once we have smart software for generating queries autonomously we can just dump these SQL developers. I dont see anything smart in SQL

- Anonymous December 20, 2010 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

The Solution is,

SELECT TOP 4 * from (SELECT * from employee ORDER BY salary DESC)

- Saravanan R March 02, 2011 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

I think question is to find top 4th record..

It may look worse in terms of performance..

select * from employee where salary = (select top 1 salary from (select top 4 salary from employee order by salary desc) order by salary asc))

- Amol March 20, 2011 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

I think question is to find top 4th record..

It may look worse in terms of performance..

select * from employee where salary = (select top 1 salary from (select top 4 salary from employee order by salary desc) order by salary asc))

- Amol March 20, 2011 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

select name, salary from employee where salary = (select distinct salary from employee order by salary desc limit 3,1);

- viviana April 18, 2011 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

select name, min(salary) from employee where salary in (select distinct top 4 salary from employee order by salary desc);

- Anonymous August 04, 2011 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

If you are being interviewd by a top company, they expect u to answer it without using any keywords that commercial db's have.. i would go with the version that was answered above
####
select name, salary
from employee t
where (select count(1) from employee t1 where t1.salary > t.salary) = 3; ####

- nag August 22, 2011 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

expect a similar question in terms of, return top 3 records etc.

- nag August 22, 2011 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

select Name, Sal from employee where sal in (select top 1 sal from employee where sal in (select distinct Top 4 sal from employee order by sal desc) order by sal desc)

- Ujjwal September 07, 2011 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

select Name, Sal from employee where sal in (select top 1 sal from employee where sal in (select distinct Top 4 sal from employee order by sal desc) order by sal desc)

- Gutts September 07, 2011 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

select a.name,a.sal from employee a where 3 = (select count(distinct(b.sal)) from employee b where b.sal >= a.sal)

- Sharath Cirupati February 26, 2012 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

select * from (select * ,rank() over (order by sal) as myorder from emp )as p
where p.myorder = 4

- shiv mohan February 27, 2012 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

I guess most of the sql here are nothing but a crude way to find the answer. Some of them are completely wrong too..

SELECT EMPNAME, SALART FROM EMPLOYEE
QUALIFY RANK() OVER(ORDER BY SALARY DESC)=4

- Anon April 27, 2012 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

select distinct TOP 4 salary FROM employee ORDER BY activity_id DESC

- KK August 24, 2012 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

select empname, salary from employee a where (4 = (select count(distinct(b.salary)) from employee b where b.salary>=a.salary))

- Anonymous September 03, 2012 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

select empname, salary
from employee
where salary =
(
SELECT salary
FROM employee
group by salary
order by salary desc
limit 3,1);

- Jo November 15, 2012 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

select * 
from employee a
where 4 > (select count(sal)
		from employee b
		where a.sal <= b.sal)

- manoj9186 November 23, 2014 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

select *
from employees e
where e.salary = (
    select distinct salary
    from employees
    order by salary desc
    limit 1 offset 3)

- Anonymous March 24, 2015 | Flag Reply
Comment hidden because of low score. Click to expand.
-1
of 1 vote

select name, salary form employee where 4=(select max(salary) from employee)

- Anonymous October 01, 2012 | Flag Reply


Add a Comment
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.

Learn More

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.

Learn More

Resume Review

Most engineers make critical mistakes on their resumes -- we can fix your resume with our custom resume review service. And, we use fellow engineers as our resume reviewers, so you can be sure that we "get" what you're saying.

Learn More

Mock Interviews

Our Mock Interviews will be conducted "in character" just like a real interview, and can focus on whatever topics you want. All our interviewers have worked for Microsoft, Google or Amazon, you know you'll get a true-to-life experience.

Learn More