Amazon Interview Question for Software Engineer / Developers






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

<pre lang="java" line="1" title="CodeMonkey47229" class="run-this">create table temp(id int primary key, value nvarchar(256))

insert into temp values(1,'a')
insert into temp values(2,'b')
insert into temp values(3,'b')
insert into temp values(4,'c')


select distinct t1.value
from temp t1,temp t2
where t1.value = t2.value
and t1.id <> t2.id

--OR

select count(*),t.value
from temp t
group by t.value
having count(*) > 1</pre><pre title="CodeMonkey47229" input="yes">
</pre>

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

a primary key cannot be double it has unique values ?????/

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

I think the interviewer is curious about the GROUP BY in Database.

- Karthik February 17, 2011 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

Question is not clear. How were duplicate rows inserted into the table when it has a primary key?

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

assuming primary key is logical and no PK constraint created

select * from order a where rowid in
(select min(rowid) from order b where a.orderid=b.orderid)

- praveen May 14, 2012 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

select t1.id, t2.id, t1.name
from orderT t1, orderT t2
where t1.name=t2.name and t1.id>t2.id

- aileen April 20, 2013 | Flag Reply
Comment hidden because of low score. Click to expand.
-1
of 1 vote

hi

- Anonymous January 11, 2011 | 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