Interview Question for Software Engineer / Developers


Country: United States
Interview Type: In-Person




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

Try this out

Select CustomerName
From Customer C 
Left Join OrderTable O on C.custom_fk=O.custom_fk
Join OrdersItems OI on OI.order_fk = O.order_fk
Where 
	DATEDIFF(mm,Isnull(order_date, '1/1/1900'), getdate() ) < 6
and O.Id is null 
and OI.ID is null

- Jai December 07, 2014 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

If a customer hasn't placed an order, how do you make a where cause as the order date is null?

- fz December 07, 2014 | Flag
Comment hidden because of low score. Click to expand.
1
of 1 vote

Again check for null and assign it value where you can calculate the range... that is all..

- Jai December 07, 2014 | Flag
Comment hidden because of low score. Click to expand.
0
of 2 vote

why you join OrdersItems while he don't request it , the query just like :

select custName from cust c left outer join order o on (r.id = o.custId)
where o.custId is null AND DATEDIFF(orderDate , getDate()) <6;

- sara January 01, 2015 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

select c.customerName from Customer c
left outer join Order o
on c.id = o.custom_fk
where DATEDIFF(mm,Order_date,Getdate())<= 6
OR o.custom_fk IS NULL

- Anonymous January 13, 2015 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

shouldn't be
where DATEDIFF(mm,Order_date,Getdate())<= 6
AND o.custom_fk IS NULL

- Anonymous May 06, 2015 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 votes

OR will be the right one.

- Anonymous June 12, 2015 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 vote

select y.customerid, x.customerid
from
(select customerid, orderdate, datediff(orderdate, curdate())
from orders where datediff(orderdate, curdate()) < 0 and
datediff(orderdate, curdate()) >= -180
order by (datediff(orderdate, curdate()) < 0 and
datediff(orderdate, curdate()) >= -180) asc) x
right outer join customer y on x.customerid = y.customerid
where x.customerid is null

- Manish March 01, 2015 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

{select y.customerid, x.customerid
from
(select customerid, orderdate, datediff(orderdate, curdate())
from orders where datediff(orderdate, curdate()) < 0 and
datediff(orderdate, curdate()) >= -180
order by (datediff(orderdate, curdate()) < 0 and
datediff(orderdate, curdate()) >= -180) asc) x
right outer join customer y on x.customerid = y.customerid
where x.customerid is null}

- Manish March 01, 2015 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

{select y.customerid, x.customerid
from
(select customerid, orderdate, datediff(orderdate, curdate())
from orders where datediff(orderdate, curdate()) < 0 and
datediff(orderdate, curdate()) >= -180
order by (datediff(orderdate, curdate()) < 0 and
datediff(orderdate, curdate()) >= -180) asc) x
right outer join customer y on x.customerid = y.customerid
where x.customerid is null}

- manish.bhoge March 01, 2015 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

SELECT DISTINCT(id)
  FROM custom c
  WHERE c.id NOT IN
    (SELECT DISTINCT(o.id)
     FROM `order` o
     WHERE TIMESTAMPDIFF(MONTH, getdate(), o.date) <= 6)

- Anonymous June 01, 2015 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

SELECT customer_fk, MAX(order_date) AS latest_ord_date
INTO #LatestOrd
FROM order_tab

SELECT A.id AS order_id
		, A.customer_fk
		, A.order_date
		, (DATEDIFF(day, TODAY(), A.order_date) * 1.0 / 7.0 / 26.0) AS latest_ord_bi_ann

INTO #t2
FROM order_tab AS A JOIN #LatestOrd AS B ON (A.customer_fk == B.customer_fk AND A.order_date = B.latest_ord_date);

SELECT *
FROM #t2
WHERE latest_ord_bi_ann > 0;

- Jeevan June 04, 2016 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

select c.customer_id
from customer c LEFT OUTER JOIN order o
ON o.cust_fk = c.id
where order_date < TRUNC(ADD_MONTHS(SYSDATE, -6));

I think using TRUNK is appropriate here

- sk October 24, 2016 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

select * from cust c
left outer join orders o on c.custid=o.orderid
where (orderdate is null
or
DATEDIFF(mm,orderdate,GETDATE())>=6)

- Anonymous May 03, 2017 | 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