clear markdown compare help donate comments/suggestions/bugs a leap of faith? bible365 diddy dollings
clear markdown donate comments/suggestions/bugs a leap of faith? bible365 diddy dollings
By using db<>fiddle, you agree to license everything you submit by Creative Commons CC0. 541799 fiddles created (11226 in the last week).

CREATE TABLE Invoices ( InvoiceNum INT NOT NULL, Amount DECIMAL, RecordPK UNIQUEIDENTIFIER NOT NULL ); CREATE TABLE Records( RecordPK UNIQUEIDENTIFIER NOT NULL PRIMARY KEY, StartNum INT NOT NULL, NextNum INT NOT NULL, MaxNum INT NOT NULL, InvPrefix VARCHAR(2) NOT NULL ); INSERT INTO Invoices VALUES (1 , 19.00, 'EDFA0541-5583-4CDD-BDFF-21D6F6504522'), (2 , 50.00, 'EDFA0541-5583-4CDD-BDFF-21D6F6504522'), (3 , 3.00 , 'EDFA0541-5583-4CDD-BDFF-21D6F6504522'), (10 , 1.00 , 'D64EFF0E-65D5-467E-8C82-BFBB6A24AAC9'), (11 , 99.00, 'D64EFF0E-65D5-467E-8C82-BFBB6A24AAC9'), (12 , 13.00, 'D64EFF0E-65D5-467E-8C82-BFBB6A24AAC9'); INSERT INTO Records VALUES ('EDFA0541-5583-4CDD-BDFF-21D6F6504522', 1 , 4 , 10, 'AA'), ('D64EFF0E-65D5-467E-8C82-BFBB6A24AAC9', 10, 13, 14, 'AA'); SELECT I.*, CASE WHEN I.InvoiceNum IS NULL THEN 'Blank' END Remark FROM (VALUES (1), (2), (3), (4), (5), (6), (7), (8), (9), (10), (11), (12)) RC (InvoiceNum) LEFT JOIN Invoices I ON RC.InvoiceNum = I.InvoiceNum
InvoiceNum Amount RecordPK Remark
1 19 edfa0541-5583-4cdd-bdff-21d6f6504522
2 50 edfa0541-5583-4cdd-bdff-21d6f6504522
3 3 edfa0541-5583-4cdd-bdff-21d6f6504522
Blank
Blank
Blank
Blank
Blank
Blank
10 1 d64eff0e-65d5-467e-8c82-bfbb6a24aac9
11 99 d64eff0e-65d5-467e-8c82-bfbb6a24aac9
12 13 d64eff0e-65d5-467e-8c82-bfbb6a24aac9
 hidden batch(es)