my approach with cte as ( select *, round(avg(quantity) over(partition by order_id),0) avg ,max(quantity) over(partition by order_id) total from orders) select distinct order_id, total from cte where quantity >= (select max(avg) from cte);
with cte as (select *, round(avg(quantity) over(partition by order_id),0) avg ,max(quantity) over(partition by order_id) total from orders) select distinct order_id from cte where total >= (select max(avg) from cte);
my approach it's quite lengthy when you see first but it is understandable format with cte1 as( select order_id, (sum(quantity)/count(distinct product_id)) as avg_ from e_comm group by order_id), cte2 as( select order_id,max(quantity) as max_ from e_comm group by order_id), cte3 as( select c1.order_id,c1.avg_,c2.max_ from cte1 c1 inner join cte2 c2 on c1.order_id=c2.order_id) select order_id from cte3 where max_>(select max(avg_) from cte3) order by order_id;
Hello nishtha, I watched your hackerank sql solving videos. They were pretty good. I saw your channel is new. I want to know from you that what are the resources are there to learn SQL very properly. I would like to mention that I want to learn this by myself. can you mention some books and resources by which I can be keen at data science. THANK YOUUUUUUU
Please also post script for practice
my approach
with cte as (
select *, round(avg(quantity) over(partition by order_id),0) avg ,max(quantity) over(partition by order_id) total from orders)
select distinct order_id, total from cte where quantity >= (select max(avg) from cte);
mam plewse start a series from 0 to hero in SQL...i really want to learn from you
with cte as (select *, round(avg(quantity) over(partition by order_id),0) avg ,max(quantity) over(partition by order_id) total from orders)
select distinct order_id from cte where total >= (select max(avg) from cte);
my approach
it's quite lengthy when you see first but it is understandable format
with cte1 as(
select order_id, (sum(quantity)/count(distinct product_id)) as avg_ from e_comm
group by order_id),
cte2 as(
select order_id,max(quantity) as max_ from e_comm
group by order_id),
cte3 as(
select c1.order_id,c1.avg_,c2.max_
from cte1 c1
inner join cte2 c2
on c1.order_id=c2.order_id)
select order_id
from cte3
where max_>(select max(avg_) from cte3)
order by order_id;
Hello nishtha, I watched your hackerank sql solving videos. They were pretty good. I saw your channel is new.
I want to know from you that what are the resources are there to learn SQL very properly. I would like
to mention that I want to learn this by myself. can you mention some books and resources by which I can be keen at data science. THANK YOUUUUUUU
If there is anything most valuable in God's treasure, it is human life. The goal of life is to understand life.
i can't find script to solve my self first