sql带条件查找最小缺失编号

xiaoxiao2021-02-28  104

查找在CASE_SET_ID为某个条件下的最小缺失编号 如 1 3 获取的值是2 , 2 3则获取的值是1 /** * select * case when not exists(select * from rt_test_case where CASE_NUM=1) then 1 * else (select min(IFNULL(CASE_NUM,0)+1) from rt_test_case as a * where * not exists( * select CASE_NUM * from rt_test_case as b * where IFNULL(a.CASE_NUM,0)+1=b.CASE_NUM AND a.CASE_SET_ID = b.CASE_SET_ID * ) and CASE_SET_ID = '10383') end * */
转载请注明原文地址: https://www.6miu.com/read-34418.html

最新回复(0)