I have table with identity column seqno. I want to find missing no in this column.
Note : I have only read permission in this table only.
My code:
SELECT Rno
FROM
(SELECT
seqno, ROW_NUMBER() OVER (ORDER BY seqno) AS Rno
FROM trnmast) a
WHERE
seqno <> rno
I run this but not getting correct result.
Example :
| SeqNo |
|---|
| 1 |
| 3 |
| 4 |
| 7 |
| 8 |
| 10 |
I want only missing no like this :
| seqNo |
|---|
| 2 |
| 5 |
| 6 |
| 9 |
I have only read permission of this table only.