johanntagle icon

postgresql crosstab

johanntagle | PRO | 05/07/19 09:34:49 PM UTC | 0 ⭐ | 7048 👁️ | Never ⏰ | []
PostgreSQL |

340 B

|

None

|

0 👍

/

0 👎

select * from crosstab(
'select extract(year from starts) as year,
extract(month from starts) as month,
count(*)
from events
group by year, month
order by year, month',
'select * from month_count'
) as (
year int, 
jan int, feb int, mar int, apr int, may int, jun int, 
jul int, aug int, sep int, oct int, nov int, dec int
) order by year;

Comments

  •  icon
    01/01/70 12:00:00 AM UTC
    Plain Text |

    0 B

    |

    👍

    /

    👎

    
        
  •  icon
    01/01/70 12:00:00 AM UTC
    Plain Text |

    0 B

    |

    👍

    /

    👎