我有下列的表:的Oracle SQL查詢沒有顯示正確的價值
- ID
- 技術
- name_event
- time_event
我算的數表中的值用以下查詢
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)
個
我以下插入
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);
我在狀態1插入的10行和移動2至狀態2,所以應該有狀態1 8項時我執行查詢,但結果是10。 ..
我在做什麼錯?
如何提供這些10插入語句以及創建表腳本? –
除非我們有你的樣本數據,否則我們很難看到你做錯了什麼 - 你能添加表格定義和插入語句嗎? – ninesided
可否請您在表格中提供一些示例數據,然後我們可以更快地提供答案 –