'how to implement CrossTab in postgresql

I want to convert data from format a to format b in PostgreSQL, any help would be great-full.

reference image with existing format



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source