只是想知道是否有人可以帮忙解决这个问题?我在Quality Center v9中创建了一些xls报告。
通过累加,我的子总数基于' cy_cycle'专栏以及整体总数。
查询: 是否可以合并列&#c; cy_cycle' &安培; ' cf_item_name'只有在列' cy_cycle'的这些子行总数的位置显示?
我曾尝试使用concat等案例,但没有运气,所以毫无疑问朝着错误的方向前进,不确定它是否真的可以完成?
ps - 有一个参数 - ' Report_Date'
Select nvl(cy_cycle, '# Total for ........ ' ) as "QC Test Set"*
,nvl(cf_item_name,'## DAILY TOTAL ##') as "Parent Folder"
,@Report_Date@ as "Report Date"
,count(TC_Status) as "Test Set Total"
,SUM(case when TC_Status = 'Passed' then 1 else 0 end) as "Passed"
,Sum(case when TC_Status = 'Failed' then 1 else 0 end) as "Failed"
,Sum(case when TC_Status = 'Blocked' then 1 else 0 end) as "Blocked"
,Sum(case when TC_Status = 'Not Completed' then 1 else 0 end) as "Not Completed"
,Sum(case when TC_Status = 'N/A' then 1 else 0 end) as "Not Applicable"
,Sum(case when TC_Status = 'No Run' then 1 else 0 end) as "No Run"
,Sum(case when TC_Status = 'De-Scoped' then 1 else 0 end) as "De-Scoped"
From (TESTCYCL inner join CYCLE on tc_cycle_id=cy_cycle_id) inner join CYCL_FOLD on cy_folder_id=cf_item_id
Where cy_folder_id in(Select cf_item_id From CYCL_FOLD Where cf_item_path like 'AAAABBAAIAAE%')--**Pre-Pop Final_1**
and trunc(tc_exec_date) = trunc(to_date( @Report_Date@ ,'DD-MON-YYYY'))
group by rollup(cf_item_name, cy_cycle)
感谢目前为止的回复。
参考DBMS - 它的Oracle。
Prob在请求中并不清楚 - 我看到我是否可以合并列&q; qc_test_set' &安培; ' Parent_folder'仅适用于列&q; qc_test_set'中的那些记录的位置是null(我使用nvl给' Total ...' 但不显示任何其他列? {例如记录3,5,9&列1和10之下的10 2将合并/连接在一起}
目前它显然是纯粹的化妆品和可读性,但我想如果我可以合并这些,那么我也可以正确对齐以便于阅读。
(我已经删除了一些记录,因此整体总数不在下面)
QC Test Set Parent Folder Report Date Test Set Total Passed
----------- ------------- ----------- -------- ----- ------
Branch CR95 10-May-16 11 11
Business CR95 10-May-16 5 5
# Total for .... CR95 10-May-16 16 16
Issue 49 04 Misc 10-May-16 4 4
# Total for .... 04 Misc 10-May-16 4 4
Personal 01 Pre-Des 10-May-16 6 6
Personal 01 Pre-Des 10-May-16 2 2
Non-Personal 01 Pre-Des 10-May-16 2 2
# Total for .... 01 Pre-Des 10-May-16 10 10
# Total for .... ## DAILY TOTAL ## 10-May-16 44 42
答案 0 :(得分:0)
我不确定你到底是什么意思:
仅适用于列' cy_cycle'的这些子总行数。显示
如果你碰巧想要将cy_cycle
和cf_item_name
连接到cy_cycle不为null的地方,那么CASE
应该可以正常工作:
Select nvl(cy_cycle, '# Total for ........ ' ) as "QC Test Set"*
,nvl(cf_item_name,'## DAILY TOTAL ##') as "Parent Folder"
, CASE WHEN cy_cycle IS NULL THEN '' ELSE cy_cycle + cf_item_name END AS CycleItemMerge
,@Report_Date@ as "Report Date"
,count(TC_Status) as "Test Set Total"
,SUM(case when TC_Status = 'Passed' then 1 else 0 end) as "Passed"
,Sum(case when TC_Status = 'Failed' then 1 else 0 end) as "Failed"
,Sum(case when TC_Status = 'Blocked' then 1 else 0 end) as "Blocked"
,Sum(case when TC_Status = 'Not Completed' then 1 else 0 end) as "Not Completed"
,Sum(case when TC_Status = 'N/A' then 1 else 0 end) as "Not Applicable"
,Sum(case when TC_Status = 'No Run' then 1 else 0 end) as "No Run"
,Sum(case when TC_Status = 'De-Scoped' then 1 else 0 end) as "De-Scoped"
From (TESTCYCL inner join CYCLE on tc_cycle_id=cy_cycle_id) inner join CYCL_FOLD on cy_folder_id=cf_item_id
Where cy_folder_id in(Select cf_item_id From CYCL_FOLD Where cf_item_path like 'AAAABBAAIAAE%')--**Pre-Pop Final_1**
and trunc(tc_exec_date) = trunc(to_date( @Report_Date@ ,'DD-MON-YYYY'))
group by rollup(cf_item_name, cy_cycle)
这假定cy_cycle
& cf_item_name
已经是字符串/字符数据类型(因此,不需要在其中包含CONVERT
或TO_CHAR
。