This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
select customer_id, state_, profit_total, | |
row_number() over(partition by state_ order by profit_total desc) as Rank_row | |
from customer_order_window; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
select customer_id, state_, profit_total, | |
dense_rank() over(partition by state_ order by profit_total desc) as Rank_row | |
from customer_order_window; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
select customer_id, state_, profit_total, | |
rank() over(partition by state_ order by profit_total desc) as Rank_row | |
from customer_order_window; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
select customer_id, state_, profit_total, | |
sum(profit_total)over(partition by state_) as state_profit_total | |
from customer_order_window; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
select customer_id, state_, profit_total, | |
avg(profit_total) over(partition by state_) as AVG_ | |
from customer_order_window; |
NewerOlder