Это видео недоступно.
Сожалеем об этом.
Day 5: Solving Walmart SQL Interview Questions | 100 Days Challenge
HTML-код
- Опубликовано: 11 июл 2024
- Welcome to Day 5 of my 100 Days Challenge! Today, we're diving into Walmart SQL interview questions to help you ace your next tech interview. Join me as I walk through each problem step-by-step, providing detailed explanations and practical tips. Don't forget to like, subscribe, and hit the bell icon to stay updated with daily challenges!
Join the 100 Days Challenge Community:
Discord: / discord
GitHub: github.com/naj...
Relevant Playlists:
SQL Interview Prep: • SQL Challenge - Data A...
#AmazonInterview #SQLInterviewQuestions #100DaysChallenge #DataScience #SQLTutorial #TechInterviews #DataAnalysis #LearnSQL #InterviewPrep #CodingChallenge #TechCareer #SQLPractice #AmazonTech #DataEngineering #PythonInterview #ExcelTips"
with cte as(select *,sum(sales_amount) over(partition by store_name rows between unbounded preceding and current row)as running_sales,
lag(sales_amount,1,sales_amount) over(partition by store_name)as prev_month_sales from sales)
select *,round((sales_amount-prev_month_sales)/prev_month_sales*100,2) as growth_rate from cte
i think null value on the 1st row or in the other cases for the first month we may assume the initial value as the value instead of null & to get that i have used--- lag(sales_amount,1,sales_amount)
select *,
case when lagging is not null then round(((sales_amount - lagging)/lagging) * 100,2) else 0 end as growth_ratio
from(
select * ,sum(sales_amount) over(partition by store_name order by sale_date) as sum,
lag(sales_amount) over(partition by store_name order by store_name) as lagging
from sales) as Subquery
SOLUTION IN SQL SERVER :
with cte as (
select store_name,DATEPART (month,sale_date) as sale_month,sum(sales_amount) as total_sale_amount
from sales
group by store_name,DATEPART (month,sale_date)
),
cte2 as (select *,
sum(total_sale_amount) over (partition by store_name order by total_sale_amount ) as running_sale_amount,
lag(total_sale_amount,1) over (partition by store_name order by total_sale_amount ) as previous_sale_amount
from cte
)
select *, (total_sale_amount - previous_sale_amount)/previous_sale_amount*100 as diff
from cte2;
Hey will u explain the way of approch step when,what,how to analyse what is to use..I am facing dificulty to analyse the same
Sure!