Skip to content
Advertisement

How can we achieve the below output (PostgreSQL)

I need to calculate the Numerator and Denominator values for one metric called Payments% and the formulae for numerator is count(distinct id) where menuaction in (‘Billpayment’, Renewal’)

Denominator formulae is count(distinct id) and I need the below columns in output using postgresql database.

Table Date:

enter image description here

Can someone please help on this scenario

Thanks in advance!

Advertisement

Answer

A window function would have been the right solution if DISTINCT had been implemented for it. Then sub queries will help :

User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement