,所以我有這個疑問的作品好,做一些數學與獨特的參數SQL查詢,其中statment
我想改變的是,第三列
的唯一的值將被納入賬戶
這是可能的嗎?
謝謝大家!
SELECT t1.[customer_id] as customer_id,t2.total AS n_results ,
FORMAT((t2.total/t1.total)*100, 'N2') AS fail_rate
FROM (SELECT [customer_id],
1.0*COUNT(*) AS Total
FROM [customer_transactions]
WHERE [customer_id] != '' AND [customer_id] NOT LIKE 'D_%'
GROUP BY
[customer_id]
) t1 JOIN (
SELECT [customer_id],
1*COUNT(*) AS Total
FROM [customer_transactions] where [result]='fail'
GROUP BY
[customer_id]
) t2
ON t1.[customer_id]=t2.[customer_id] ORDER BY fail_rate desc
這是我不清楚你想達到的目標。請您能提供一些示例數據以及您希望得到的結果。 – MatBailie