Help with SQL statement to pivot field values into column headers

Brass Contributor

 

Hello all, I've managed to filter all the data I need but I'm struggling to pivot the [Milestones].[Name] column into headers (there are 25 unique values in this field). 

 

Syntax so far which works:

Screenshot 2020-02-27 at 15.23.24.png

 

The result I need is something like this:

Screenshot 2020-02-27 at 13.45.35.png 

 

I've tried to manually pivot the "Name" field using case statements, but I'm not trying to calculate the values so I'm confused about the need to use aggregate functions.

 

This is the syntax alerting an error:

Screenshot 2020-02-27 at 15.34.44.png

 

This is the "Milestones" table to use as columns:

Screenshot 2020-02-27 at 15.37.33.png

 

Could someone please take a look and correct the errors in the code?

 

I would appreciate any assistance offered. Many thanks in advance for your help!

1 Reply

I've found a solution for part of the problem which will pivot the Milestones into column headers. But I'm having the same issue with the aggregate function.

 

How do I display the DateTime instead of counting the entries?

 

Screenshot 2020-02-27 at 17.03.33.png