示例:
當前有表test,欄位id,click,share
我的需求是
算出同一id,click數最大的click和share,減去click第二大的click和share
SQL示例:
select * from (
select id,
first_value(click) over(partition by id order by click desc) ,
first_value(share) over(partition by id order by click desc) ,
nth_value(clidk, 2) over(partition by id order by click desc) ,
nth_value(share, 2) over(partition by id order by click desc)
from
table ) t group by 1,2,3,4;示例:
table ) t group by 1,2,3,4;
示例:
當前有表test,欄位id,click,share
我的需求是
算出同一id,click數最大的click和share,減去click第二大的click和share
SQL示例:
select * from (
select id,
first_value(click) over(partition by id order by click desc) ,
first_value(share) over(partition by id order by click desc) ,
nth_value(clidk, 2) over(partition by id order by click desc) ,
nth_value(share, 2) over(partition by id order by click desc)
from
table ) t group by 1,2,3,4;示例:
當前有表test,欄位id,click,share
我的需求是
算出同一id,click數最大的click和share,減去click第二大的click和share
SQL示例:
select * from (
select id,
first_value(click) over(partition by id order by click desc) ,
first_value(share) over(partition by id order by click desc) ,
nth_value(clidk, 2) over(partition by id order by click desc) ,
nth_value(share, 2) over(partition by id order by click desc)
from
table ) t group by 1,2,3,4;