- Code: Select all
select process_name, count(id), sum(done)
from myTable
group by process_name
Where I don't know how many processes there are
This is the result of that query
- Code: Select all
process_name | count | sum
-------------|-------|----
process_1 | 20 | 10
process_2 | 30 | 9
process_3 | 11 | 9
....
process_N | x | x
For use in the report I need it in the following format:
- Code: Select all
| process_1 | process_2 | process_3 | ... | process_N
-----------------------------------------------------------
count | 20 | 30 | 11 | | x
sum | 10 | 9 | 9 | | y
I've been looking at postgresql crosstab function, but that requires a knowledge of the nr of resulting columns. Is there anyother solution to this?