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


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