如何在Firebase数据库中将子项和值添加到父项?

时间:2019-05-25 20:40:55

标签: java android firebase-realtime-database

我试图在Firebase数据库中的父级中添加子级和值,但是由于某种原因,在添加数据后应用程序崩溃。有人能帮我吗?这是我的数据库:

Database

我已经完成了添加部分,如下所示:

Addding

但是,当我单击一个按钮后,它会返回菜单,它崩溃了。

这是我完成的代码:

WITH calculations as
(
    SELECT
        CASE 
            WHEN WO.[LOT_ID] = 501 
            AND WO.[DRY_RUN_FLAG] != 1 
            AND WO.[COMPLETED_DATE] IS NOT NULL 
            AND T.[TASK_TYPE_ID] = 2 
            AND WO.[WORK_ORDER_ID] IS NOT NULL THEN 1 --the last condition is to simulate COUNT(WO.[WORK_ORDER_ID])
        ELSE 0
        END AS part1
       ,CASE
            WHEN WO.[LOT_ID] = 501 
            AND T.[TASK_TYPE_ID] = 2
            AND WO.[WORK_ORDER_ID] IS NOT NULL THEN 1 --the last condition is to simulate COUNT(WO.[WORK_ORDER_ID])
        ELSE 0
        END AS part2
    FROM [NCH].[nch].[WORK_ORDER] WO 
    JOIN [NCH].[nch].[TASK] T 
        ON WO.[TASK_ID] = T.[TASK_ID] 
)
SELECT
    (cast(sum(part1) as numeric(18,6)) / cast(sum(part2) as numeric(18,6))) * 100 as calculation
from calculations

}

这是错误消息:

Error

有人可以帮我吗?

0 个答案:

没有答案