1
我有此查詢顯示有關主題中出現的情況下的頻率和BPostgreSQL的 - 從查詢列百分比
select subject,
count(subject) as frequency,
count(case when result='OK' then 1 else null end) as case_a,
count(case when result='NG' then 1 else null end) as case_b,
round(
(
(count(case when result='OK' then 1 else null end)*100.00)/count(subject)),4)
)
from test
group by subject
我猜測,如果有一個更好的情況下,A的外觀的百分比的信息更高級的方式來計算百分比,而不必再次應用計數情況。
round(((case_a*100.00)/frequency),4)
試圖引用這樣的列^但不起作用。
這個子查詢方法當然有趣,謝謝。 –