I am trying to get the total count for a specific "COMPONENT_DATA_POINT"."NAME"
as it relates to the "DATA_POINT_UPLOAD_DATA"."VALUE"
. For example, here is my current query:
select "DATA_POINT_UPLOAD_DATA"."VALUE" as "EQUIP_ONLINE_VALUE"
from "DB"."DATA_POINT_UPLOAD_DATA" "DATA_POINT_UPLOAD_DATA"
where
"DATA_POINT_UPLOAD_DATA"."COMPONENT_UPLOAD_DATA_ID" IN (select id from (select "COMPONENT_UPLOAD_DATA".* from "DB"."COMPONENT_UPLOAD_DATA" "COMPONENT_UPLOAD_DATA",
"DB"."COMPONENT" "COMPONENT"
where
"COMPONENT_UPLOAD_DATA"."DATA_COLLECTED_TIME" < CURRENT_DATE
and "COMPONENT_UPLOAD_DATA"."COMPONENT_NO"='1'
and "COMPONENT_UPLOAD_DATA"."SITE_UPLOAD_DATA_SITE_ID"="COMPONENT"."SITE_ID"
and "COMPONENT_UPLOAD_DATA"."COMPONENT_ID"="COMPONENT"."ID"
and "COMPONENT"."COMPONENT_TYPE_ID" = '123'
and "COMPONENT"."SITE_ID" in ('123ABC')
ORDER BY "COMPONENT_UPLOAD_DATA"."DATA_COLLECTED_TIME" DESC)
where rownum <= 1)
and "DATA_POINT_UPLOAD_DATA"."COMPONENT_DATA_POINT_ID" IN (select COMPONENT_DATA_POINT_ID from (select "DATA_POINT_UPLOAD_DATA".*
from "DB"."COMPONENT_DATA_POINT" "COMPONENT_DATA_POINT",
"DB"."DATA_POINT_UPLOAD_DATA" "DATA_POINT_UPLOAD_DATA",
"DB"."COMPONENT" "COMPONENT"
where "DATA_POINT_UPLOAD_DATA"."COMPONENT_DATA_POINT_ID"="COMPONENT_DATA_POINT"."ID"
and "COMPONENT_DATA_POINT"."NAME" ='EquipUp'
and "COMPONENT_DATA_POINT"."COMPONENT_ID" = "COMPONENT"."ID"
and "COMPONENT"."COMPONENT_TYPE_ID" = '123'
and "COMPONENT"."SITE_ID" in ('123ABC')));
Current output I believe only shows one count, and not a total sum of all 'EquipUp'
:
EQUIP_ONLINE_VALUE
------------------------
1
I would like to get a total 'EQUIP_ONLINE_VALUE'
sum of all 'EquipUp'
names.
Any help would be greatly appreciated.
Thanks.
答案 0 :(得分:0)
运行这两个脚本以确定您拥有正确的数据:
SELECT "COMPONENT_UPLOAD_DATA".*
FROM "DB"."COMPONENT_UPLOAD_DATA" "COMPONENT_UPLOAD_DATA"
,"DB"."COMPONENT" "COMPONENT"
WHERE "COMPONENT_UPLOAD_DATA"."DATA_COLLECTED_TIME" < CURRENT_DATE
AND "COMPONENT_UPLOAD_DATA"."COMPONENT_NO" = '1'
AND "COMPONENT_UPLOAD_DATA"."SITE_UPLOAD_DATA_SITE_ID" = "COMPONENT"."SITE_ID"
AND "COMPONENT_UPLOAD_DATA"."COMPONENT_ID" = "COMPONENT"."ID"
AND "COMPONENT"."COMPONENT_TYPE_ID" = '123'
AND "COMPONENT"."SITE_ID" IN ('123ABC')
ORDER BY "COMPONENT_UPLOAD_DATA"."DATA_COLLECTED_TIME" DESC
SELECT "DATA_POINT_UPLOAD_DATA".*
FROM "DB"."COMPONENT_DATA_POINT" "COMPONENT_DATA_POINT"
,"DB"."DATA_POINT_UPLOAD_DATA" "DATA_POINT_UPLOAD_DATA"
,"DB"."COMPONENT" "COMPONENT"
WHERE "DATA_POINT_UPLOAD_DATA"."COMPONENT_DATA_POINT_ID" = "COMPONENT_DATA_POINT"."ID"
AND "COMPONENT_DATA_POINT"."NAME" = 'EquipUp'
AND "COMPONENT_DATA_POINT"."COMPONENT_ID" = "COMPONENT"."ID"
AND "COMPONENT"."COMPONENT_TYPE_ID" = '123'
AND "COMPONENT"."SITE_ID" IN ('123ABC')