如何检查某些列中的缺失数字
How to check missing number in some column
我使用Mysql和spring数据jpa
我对如何查找某些列的缺失数据有疑问
该列属性是 int。
So.if 我在某个数据列中插入了一些数据。
人数table
seq | number | sometext | someData | something | some | some
当我像这样插入数据时。
1 0 sometext someData something some some,
2 2 sometext someData something some some,
3 3 sometext someData something some some,
4 5 sometext someData something some some,
5 10 sometext someData something some some,
如何获取我缺少的数字列
在spring数据jpa原生查询。
这个查询怎么样
SELECT CONCAT(X.EXPECTED, IF(X.GOT-1>X.EXPECTED, CONCAT(' ~ ',X.GOT-1), '')) AS MISSING
FROM (
SELECT
@ROWNUM:=@ROWNUM+1 AS EXPECTED,
IF(@ROWNUM=B.number , 0, @ROWNUM:=B.number ) AS GOT
FROM (SELECT @ROWNUM:=0) AS A
INNER JOIN YOUR_TABELE B
ORDER BY B.number
) AS X
WHERE X.GOT!=0;
我使用Mysql和spring数据jpa
我对如何查找某些列的缺失数据有疑问
该列属性是 int。
So.if 我在某个数据列中插入了一些数据。
人数table
seq | number | sometext | someData | something | some | some
当我像这样插入数据时。
1 0 sometext someData something some some,
2 2 sometext someData something some some,
3 3 sometext someData something some some,
4 5 sometext someData something some some,
5 10 sometext someData something some some,
如何获取我缺少的数字列
在spring数据jpa原生查询。
这个查询怎么样
SELECT CONCAT(X.EXPECTED, IF(X.GOT-1>X.EXPECTED, CONCAT(' ~ ',X.GOT-1), '')) AS MISSING
FROM (
SELECT
@ROWNUM:=@ROWNUM+1 AS EXPECTED,
IF(@ROWNUM=B.number , 0, @ROWNUM:=B.number ) AS GOT
FROM (SELECT @ROWNUM:=0) AS A
INNER JOIN YOUR_TABELE B
ORDER BY B.number
) AS X
WHERE X.GOT!=0;