我有一个查询,它根据几个子查询计算一个值。子查询基于特定的时间戳。我想为许多不同时间戳的记录计算这个值。我不知道该怎么做。
基本公式为 (S11S4CreateSessionReqRcvd - S11S4CreateSessionRespAccSent) * 100 / S11S4CreateSessionRespAccSent
SELECT
((((select ref_data FROM test.sgw_S5S11 where timestamp = "2013-08-21 00:00:06" and ref_type = "S11S4CreateSessionReqRcvd" ) - (select ref_data FROM test.sgw_S5S11
where timestamp = "2013-08-21 00:00:06" and ref_type = "S11S4CreateSessionRespAccSent")) * 100) / (select ref_data FROM test.sgw_S5S11
where timestamp = "2013-08-21 00:00:06" and ref_type = "S11S4CreateSessionReqRcvd")) as MyCalc
我不知道如何粘贴到表格中,所以这是我的 csv 格式数据示例
这是我的数据示例。(我不知道如何在这里放一张表格,所以它是 CSV 格式的)
mykey,timestamp,ref_type,ref_data 1016101,"2013-08-21 00:00:06",S5S8CreateSessionReqSent,128042907 1016102,"2013-08-21 00:00:06",S5S8CreateSessionRespAccRcvd,1270888138 1016103,"2 21 00:00:06”,S5S8CreateSessionRespRejRcvd,615553 1016104,”2013-08-21 00:00:06”,S5S8CreateBearerReqRcvd,10047 1016105,”2013-08-21 00:00:06”,S5S8932,1016106 2013-08-21 00:00:06",S5S8CreateBearerRespRejSent,103 1016107,"2013-08-21 00:00:06",S11S4CreateSessionReqRcvd,128255390 1016108,"2013-08-21 00:00:06",S11S4RespAcc 127114539 1016109,"2013-08-21 00:00:06",S11S4CreateSessionRespRejSent,713325 1016110,"2013-08-21 00:00:06",S11S4CreateBearerReqSent,10028 10161110,"2013-06-02 ",S11S4CreateBearerRespAccRcvd,9932 1016112,"2013-08-21 00:00:06",S11S4CreateBearerRespRejRcvd,42
任何帮助将不胜感激!!!