Skip to content
Advertisement

MySQL show proportion

I am trying to show a proportion of customers that signed up because he/she was being referred by other customers and customers with no referral. So far I only able to show it as numerical but I wanted to show it in percentage. Null is when the customer signs up without being referred.

The original data as follows:

The query that I have and return data as follows:

Expected result

Any suggestion to show it as a percentage? Thank you in advance

Advertisement

Answer

Use aggregate function AVG():

See the demo.
Results:

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