-1

I have a table something similar to below.

Regions | Num | Date
USA       1     20/9/2021
USA       2     20/9/2021
USA       1     20/9/2021
USA       4     20/9/2021
USA       1     05/8/2021
USA       1     05/8/2021
USA       6     05/8/2021

What I want to achieve is the below

Name of KPI            | AUG 21 | SEP 21
Total number for month     8       8

I am currently using pivot to do the same but each time we add a new month I have to update my query. Trying to make it a bit more automated.

Dale K
  • 25,246
  • 15
  • 42
  • 71
ragethewolf
  • 160
  • 1
  • 10
  • 1
    Does this answer your question? [SQL Server dynamic PIVOT query?](https://stackoverflow.com/questions/10404348/sql-server-dynamic-pivot-query) – Thom A Sep 20 '21 at 09:38

1 Answers1

1

Please try with dynamic pivot. It's very easy to implement. You can take help from below link.

SQL Server dynamic PIVOT query?

Nitika
  • 437
  • 2
  • 10