Amazon Interview Question for Software Engineer / Developers






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

SELECT * FROM CustomerOrders WHERE OrderDate > sysdate - 1;

AND

SELECT * FROM CustomerOrders WHERE customerID IN
(
SELECT customerID FROM CustomerOrders WHERE OrderDate > sysdate - 1
INTERSECT
SELECT customerID FROM CustomerOrders WHERE TO_DATE(OrderDate,'DD-MON-YYYY') > TO_DATE(SYSDATE,'DD-MON-YYYY') - 2 AND
TO_DATE(OrderDate,'DD-MON-YYYY') < TO_DATE(SYSDATE,'DD-MON-YYYY')
);

- DG October 16, 2009 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

1. select Customer ID
from CustomersOrders
where Order Date="2009-09-02

- sneha September 02, 2009 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

2.select * from CustomerOrders
where OrderDate in ("2009-09-02","2009-09-03")
group by CustomerID
having count(OrderDate)==2

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

Well, i do notice that its been long time since anyone replied to this thread but probably this would help the new guys. A mysql version doesn't have to more complicated that this

1. SELECT * FROM CustomerOrders WHERE OrderDate = CURDATE();
2. SELECT * FROM CustomerOrders WHERE OrderDate in (CURDATE(),DATE_SUB(CURDATE(),INTERVAL 1 DAY));

- littleboy February 09, 2010 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

read the question:
Write a SQL to find all customers who has placed an order today AND yesterday.
It's AND, not OR.

- Anonymous May 18, 2010 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 vote

I think we need an inner join to do this task:

select distinct(c.Customer ID)
from CustomersOrders c, CustomersOrders c1
where c.customer Id = c1.Customer Id AND
c.Order Date= sysdate AND
c1.Order Date= sysdate

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

select custom_id from customer_order where date = today
intersect
select custom_id from customer_order where date = yesterday

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

1. SELECT CustomerID from CustomerOrders WHERE OrderDate = date();
2. SELECT CustomerID from CustomerOrders WHERE OrderDate = date()
INTERSECT
SELECT CustomerID from CustomerOrders WHERE OrderDate = (date() - 1);

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

Select CustomerID
From CustomerOrders C1
Join CustomerOrders C2
On C1.CustomerID = C2.CustomerID
and C2.orderdate = cast(getdate() as date)
and dateadd(dd,C1.OrderDate ,1) = C2.OrderDate

- Anupama August 04, 2015 | 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