要は値のバリエーションに対して、ひと手間加えたリストを取得し、それを上述のSQLに貼り付けてあげています。 このSQLで得られたbb列、cc列を上述のSQLに貼り付けることにより、割と手間をかけずにpivotのSQLを作成できます。
You can pivot data in SQL Data Warehouse by using a CASE statement. This article contains two simple examples on how to both pivot and unpivot a table without using the pivot and unpivot syntax found ...