I have a table with following columns:
- id
- technology
- name_event
- time_event
I count the number of values in a table with the following query
select 1, 'Folder' as "Technology", 'Status' as "Name_Event", count(dm1.id) as "number of items", max(TO_CHAR(TO_DATE('20000101','yyyymmdd')+(SYSDATE - dm1.time_event),'hh24:mi:ss')) as "Time in system"
from db dm1 join db dm2 on dm1.id = dm2.id
where dm1.technology = 'Folder' and dm1.name_event = 'status1' and NOT EXISTS(SELECT 1 FROM db dm2 WHERE dm2.name_event = 'status2' and dm2.id = dm1.id)
I did following inserts
INSERT INTO DB(id, technology, name_event, time_event) VALUES(1,'Folder', 'status1', 01:00:00);
INSERT INTO DB(id, technology, name_event, time_event) VALUES(2,'Folder', 'status1', 01:00:00);
INSERT INTO DB(id, technology, name_event, time_event) VALUES(3,'Folder', 'status1', 01:00:00);
INSERT INTO DB(id, technology, name_event, time_event) VALUES(4,'Folder', 'status1', 01:00:00);
INSERT INTO DB(id, technology, name_event, time_event) VALUES(5,'Folder', 'status1', 01:00:00);
INSERT INTO DB(id, technology, name_event, time_event) VALUES(6,'Folder', 'status1', 01:00:00);
INSERT INTO DB(id, technology, name_event, time_event) VALUES(7,'Folder', 'status1', 01:00:00);
INSERT INTO DB(id, technology, name_event, time_event) VALUES(8,'Folder', 'status1', 01:00:00);
INSERT INTO DB(id, technology, name_event, time_event) VALUES(9,'Folder', 'status1', 01:00:00);
INSERT INTO DB(id, technology, name_event, time_event) VALUES(10,'Folder', 'status1', 01:00:00);
INSERT INTO DB(id, technology, name_event, time_event) VALUES(4,'Folder', 'status2', 02:00:00);
INSERT INTO DB(id, technology, name_event, time_event) VALUES(1,'Folder', 'status2', 03:00:00);
I inserted 10 rows in status 1 and moved 2 to status 2. So there should be 8 items in status 1 when I execute the query, but the result is 10...
What am I doing wrong?