Create
table
T1
(Id
int
identity
primary
key
,
VoucherNo
varchar
(4),
TransNo
(10)
)
Insert
into
values
(
'V100'
'Trns1'
),(
'V101'
'V102'
'V103'
'V104'
'V106'
;
WITH
cte
AS
SELECT
*
CAST
SUBSTRING
(VoucherNo, 2, 3)
INT
) - ROW_NUMBER() OVER (
ORDER
BY
Grp
FROM
min
(VoucherNo)
FirstVoucherNo
max
LastVoucherNo
count
(*)
Quantity
GROUP
,Grp
Naomi N edited Revision 14. Comment: Added See Also
Naomi N edited Revision 5. Comment: Minor edit
Naomi N edited Revision 4. Comment: Minor edit
Naomi N edited Revision 3. Comment: Minor grammar corrections
Naomi N edited Revision 2. Comment: Minor grammar corrections
Naomi N edited Revision 1. Comment: Title case
Naomi N edited Original. Comment: Links
Y3T7BWJD55WC
Naomi N edited Revision 15. Comment: Added link