Amazon Interview Question for Software Engineer / Developers






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

select * from CustOrder where to_char(order_date)=to_char(current_date - 1);

select count(*) from CustOrder, CustOrderedItem where CustOrder.order_id=CustOrderedItem.order_id and to_char(CustOrder.order_date)=to_char(current_date - 1);

select order_id from CustOrder where to_char(order_date)=to_char(current_date - 1) and order_id in (select order_id from CustOrderedItem group by order_id having count(*) > 3);

select count(order_id) from CustOrder where to_char(order_date)=to_char(current_date - 1) and order_id in (select order_id from CustOrderedItem group by order_id having count(*) > 3);

- dog_faced_bastard January 24, 2011 | Flag Reply
Comment hidden because of low score. Click to expand.
1
of 1 vote

1. select * from Order where OrderDate = (date() - 1);
2. select count(*) from OrderItem where OrderID in (select OrderID from Order where OrderDate = (date() - 1));
3. select orderid from (select Order.OrderID as orderid, count(*) as count from OrderItem INNER JOIN Order on OrderItem.OrderID = Order.OrderID where Order.OrderDate = (date() - 1) group by Order.OrderID) where count > 3;
4. select count(*) from (select Order.OrderID as orderid, count(*) as count from OrderItem INNER JOIN Order on OrderItem.OrderID = Order.OrderID where Order.OrderDate = (date() - 1) group by Order.OrderID) where count > 3;

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

I think an easier way to 3) would be something like:

select orderID from order where OrderDate = (date()-1)
Intersect
select orderID from OrderItem group by orderID having count(orderID)>3

Im unsure of how correct that is..

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

For 2nd may be we can do in 1 step only --
select count(OrderID) from Order where OrderDate = (date() - 1)

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

i think sp is right..and u can use the sp answer for 4 also.

- asshole January 19, 2011 | Flag
Comment hidden because of low score. Click to expand.
1
of 1 vote

select * from OrderTab where DATEDIFF(d, OrderDate, getdate()) = 1

select count(*) from OrderTab where DATEDIFF(d, OrderDate, getdate()) = 1

select * from OrderTab inner join OrderItem 
on OrderTab.OrderId = OrderItem.OrderId
where DATEDIFF(d, OrderDate, getdate()) = 1 
group by OrderTab.OrderId, OrderDate, ItemId, OrderItem.OrderId
having Count(ItemId) > 3

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

I think the answer for the 2nd one should be:

select count(ItemId) from OrderItem where OrderItem.OrderId IN (select OrderID from Order where OrderDate=date()-1)

Correct me if I am wrong

- Anonymous March 31, 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