Skip to content
Advertisement

Postgresql: how to calculate the percentage correctly?

With this very simple query I obtain the count(total) and genre of movies from my db.

My question is: how to get a percentage? I want something like this

I have tried a lot of codes taken from gogle and stackexchange before asking, as you can see from this psql history but all fail with error or very strange results.

Advertisement

Answer

Use window functions:

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