Pergunta de entrevista da empresa Amazon

DML / DDL definitons and examples, why AWS? Tell me a creative thing you have done in your current job. SQL query - if there are store with store id and Total_sales and order date, he wanted to compare last weeks revenue to this week by store Id(which I assume because he never wrote the question properly and he just told on the fly, we have board where both of us can write but he have could written the question atleast , its hard to understand the question on the phone with his accent)

Respostas da entrevista

Sigiloso

9 de jan. de 2020

Select A.RevenueA As Week1Revenue ,B.RevenueB as Week2Revenue ,O.StoreID From Orders O Left join ( Select Sum(Revenue) As RevenueA,Storeid From Orders Group By Store_id Having Date-today()=7 And Date-Today()<=14 )B On B.StoreID=O.StoreID On the fly this could be the solution. Can be optimised but without data this could be one solution.

1

Sigiloso

25 de fev. de 2019

For comparing the weeks revenue you can use the LAG () function- select to_char(to_date(order_date,'dd-mm-yyyy'),'ww') sales_week, lag(sum(Total_sales),1,0) over (order by to_char(to_date(order_date,'dd-mm-yyyy'),'ww')) as prev_week from sales group by to_char(to_date(order_date,'dd-mm-yyyy'),'ww') order by 1;

1

Sigiloso

9 de jan. de 2020

Select A.RevenueA As Week1Revenue ,B.RevenueB as Week2Revenue ,O.StoreID From Orders A Left join ( Select Sum(Revenue) As RevenueA,Storeid From Orders Group By Store_id Having Date-today()=7 And Date-Today()<=14 )B On B.StoreID=O.StoreID On the fly this could be the solution. Can be optimised but without data this could be one solution.

1