rank 和 ROW_NUMBER 区别

SELECT  * ,
        RANK() OVER ( PARTITION BY APP_NAME ORDER BY SETTING_NAME,SETTING_CODE ASC ) AS Rank
FROM    ( SELECT    WSAPPSETTING.ID ,
                    WSAPPSETTING.APP_ID ,
                    WSAPPREGISTER.APP_NAME ,
                    WSAPPSETTING.SETTING_NAME ,
                    WSAPPSETTING.SETTING_CODE ,
                    WSAPPSETTING.SETTING_VALUE ,
                    WSAPPSETTING.REMARK
          FROM      WS_APP_SETTING WSAPPSETTING
                    INNER JOIN WS_APP_REGISTER WSAPPREGISTER ON WSAPPREGISTER.ID = WSAPPSETTING.APP_ID
          WHERE     1 = 1
        ) tt;

        SELECT  * ,
        ROW_NUMBER() OVER ( PARTITION BY APP_NAME ORDER BY SETTING_NAME,SETTING_CODE ASC ) AS ROW_NUMBER
FROM    ( SELECT    WSAPPSETTING.ID ,
                    WSAPPSETTING.APP_ID ,
                    WSAPPREGISTER.APP_NAME ,
                    WSAPPSETTING.SETTING_NAME ,
                    WSAPPSETTING.SETTING_CODE ,
                    WSAPPSETTING.SETTING_VALUE ,
                    WSAPPSETTING.REMARK
          FROM      WS_APP_SETTING WSAPPSETTING
                    INNER JOIN WS_APP_REGISTER WSAPPREGISTER ON WSAPPREGISTER.ID = WSAPPSETTING.APP_ID
          WHERE     1 = 1
        ) tt;

rank 和 ROW_NUMBER 区别_第1张图片

rank原来是会跳号的。

转载于:https://www.cnblogs.com/myloveblogs/p/10008067.html

你可能感兴趣的:(rank 和 ROW_NUMBER 区别)