Walmart Labs Interview Question for SDE-3s


Country: United States




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

WITH cte_prices AS (
    SELECT pc.product_id,
           pc.price,
           ROW_NUMBER(
             PARTITION BY pc.product_id
             ORDER BY pc.time DESC) AS rowNumber
      FROM price_changes pc
     WHERE pc.time <= @t1 )
SELECT cp.product_id,
       cp.price
  FROM cte_prices cp   
 WHERE cp.rowNumber = 1;

- Rob April 11, 2019 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

Correction: The window function should be ROW_NUMBER() OVER (...

- Rob April 12, 2019 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

SELECT PRODUCT_ID,PRICE FROM
(
SELECT S.*,
RANK() OVER (PARTITION BY PRODUCT_ID ORDER BY PRICE_TIME DESC) RANKING
FROM PRODUCT_SALES S
WHERE S.PRICE_TIME < SYSDATE-2
) WHERE RANKING=1;

- Hemraj April 15, 2019 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

select product, price, max(time) from product where time <= <time> group by product;

- verma82 April 15, 2019 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

SELECT p, c FROM price where t<=6 GROUP BY p;

- Julius April 28, 2019 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

SELECT p, c FROM price where t<=6 GROUP BY p;

- Julius April 28, 2019 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

select * from (
select product_id, 
       price,
       row_number() over (partition by product_id order by price_time desc) rown
from product_sales where price_time <= '06-Apr-2019') where rown = 1;

- Mayur May 01, 2019 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

here a is productid b is price and c is time

select i.a,i.b from t5 i inner join
(select A,max(c) as c from t5 where c <=6 group by A ) j
on i.a = j.a and i.c=j.c

- sriharsha.vemuri31 August 24, 2019 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

what if product has been updated on same timestamp multiple times?

- harish September 09, 2019 | Flag


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