回覆列表
  • 1 # 使用者834195712159

    示例:

    當前有表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;

  • 中秋節和大豐收的關聯?
  • 古風歌曲帶有戲腔的,都有哪些戲腔型別?(請舉例指出戲腔出自哪種型別)?