'percentage difference when using CASE WHEN clause POSTGRES
Is this the correct syntax? I am using the traditional method of (new/old)-1 to work out the % difference between yesterday's registrations and a week from yesterday's registrations. I am getting '0' which does not seem right...
select
sum(case when (timestampregistered::date = current_date - 1) then 1 else 0 end)
/ sum(case when timestampregistered::date = current_date - 8 then 1 else 0 end) - 1 as pct_diff
from customers_table
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
