Hello,
I am using FirebirdSQL 4.0.1 32Bit on Windows.
I have a table where it receives data from a web service automatically by another software. That data is a POS system data and it must follow an increasing sequence.
Minimized table structure is as follows:
CREATE TABLE ZREPORT
(
CCODE INTEGER NOT NULL,
ZNO INTEGER NOT NULL,
SERIAL VARCHAR(50) NOT NULL,
ZTIME TIMESTAMP NOT NULL,
ZYEAR INTEGER,
ZMONTH INTEGER,
CONSTRAINT PK_ZREPORT PRIMARY KEY (CCODE, ZNO, SERIAL, ZTIME)
);
I am using following SQL to list all records in a given month:
select
*
from
zreport
where
ccode=:ccode and
serial=:serial and
zyear=:zyear and
zmonth=:zmonth
Minimized list looks like as following:
ZNO ZTIME
1643 28.02.2022 01:30
1642 27.02.2022 01:30
1641 26.02.2022 01:30
1640 25.02.2022 01:30
1639 24.02.2022 01:30
1638 23.02.2022 02:19
1637 22.02.2022 01:30
1636 21.02.2022 01:30
Frequently, I need to check and confirm there is no missing data (all ZNO is in sequence).
If there is missing data I need to list missing ZNO numbers. It can be a separate list or It can be to have ZTIME column with NULL values for missing ZNO numbers and I can easily find them in the list.
I could not find a solution using SQL. Actually, I am not good at window functions, which may be a solution.
I would appreciate any help.
Thanks & Regards,
Ertan