Skip to content

Instantly share code, notes, and snippets.

View kiddojazz's full-sized avatar
🎯
Focusing

Temidayo Omoniyi kiddojazz

🎯
Focusing
View GitHub Profile
select * from(
select customer_id, state_, profit_total,
rank() over(partition by state_ order by profit_total desc) as Rank_row
from customer_order_window) as rank_info
where rank_row = 1;
select customer_id, state_, profit_total,
first_value(profit_total) over(partition by state_ order by profit_total desc) as first_row
from customer_order_window;
select customer_id, state_, profit_total,
LEAD(profit_total) over(partition by state_ order by profit_total desc) as Lead_row
from customer_order_window;
select customer_id, state_, profit_total,
LAG(profit_total) over(partition by state_ order by profit_total desc) as Lag_row
from customer_order_window;
select customer_id, state_, profit_total,
row_number() over(partition by state_ order by profit_total desc) as Rank_row
from customer_order_window;
select customer_id, state_, profit_total,
dense_rank() over(partition by state_ order by profit_total desc) as Rank_row
from customer_order_window;
select customer_id, state_, profit_total,
rank() over(partition by state_ order by profit_total desc) as Rank_row
from customer_order_window;
select customer_id, state_, profit_total,
sum(profit_total)over(partition by state_) as state_profit_total
from customer_order_window;
select customer_id, state_, profit_total,
max(profit_total) over( Partition by state_) as Max_profit,
min(profit_total) over( Partition by state_) as Min_profit
from customer_order_window;
select customer_id, state_, profit_total,
avg(profit_total) over(partition by state_) as AVG_
from customer_order_window;