Success rate by payment method (ClickHouse)
Success rate by payment method (ClickHouse)
In payments, for each method compute the total number of transactions total = count(), the number of successful ones successes = rows with status = 'success', and success_rate = successes / total rounded to 4 decimals. The denominator count() is always > 0 inside a group. Use countIf. Order by method. Columns: method, total, successes, success_rate.
Expected output sample
| method | total | successes | success_rate |
|---|---|---|---|
| card | 5 | 4 | 0.8 |
| crypto | 2 | 1 | 0.5 |
| paypal | 2 | 1 | 0.5 |
Sign in to see submission history
Sign inSign in to use AI Mentor
Sign inFocus radio
Paused · SomaFM · Fluid