我有一个包含以下列的表
End_date
.count_all_transactions
.count_timeouts
.request_key
.
现在我需要计算percentagetimeout
两个不同的日期并同时显示它们。我已经建立了我的查询。
我的查询如下:
Select PercentageTimeout ,
PerTimeout,
Transaction
From
(
select
T.COUNT_ALL_TRANSACTIONS as Total,
T.END_DATE as DT1,
T.COUNT_TIMEOUTS as Timeouts,
round (((T.COUNT_TIMEOUTS / T.COUNT_ALL_TRANSACTIONS) * 100)
,2) as PercentageTimeout,
R.INTERFACE_NAME as Transaction
from rpt_timeout T, dim_request R
where
T.REQUEST_KEY = R.REQUEST_KEY
AND
T.END_DATE='27 AUG 2012'
)
left outer join
(
select T1.COUNT_ALL_TRANSACTIONS as Total1,
T1.END_DATE as DT2,
T1.COUNT_TIMEOUTS as Timeouts1,
round (((T1.COUNT_TIMEOUTS / T1.COUNT_ALL_TRANSACTIONS) * 100)
,2) as PerTimeout,
R1.INTERFACE_NAME as Transaction1
from rpt_timeout T1, dim_request R1
where T1.REQUEST_KEY = R1.REQUEST_KEY
AND T1.END_DATE='20 AUG 2012'
) on Transaction = Transaction1;
这个查询给了我正确的结果,但我正在努力的是我需要列的名称作为该表中相应的 END_DATE 即:我的输出应该是
27-AUG-2012 20-AUG-2012 Transaction
0.28 0.1 Qpay
0.09 0.06 Payment