3

I have a table that currently looks like what is below. I'd like to only have one row per date and then have each EditType value be a separate column with the count so I can easily view the different types of edits based on the day. Can this be done using a pivot?

enter image description here

Or... would it be better to back up a step before I've grouped the rows in order to get the counts, like what is shown below?

enter image description here

The desired output would be something like this:

enter image description here

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
boyle.matt
  • 191
  • 1
  • 3
  • 10

1 Answers1

7
SELECT 
    Gdb
,   Tbl
,   EditDate
,   [I]
,   [U]
,   [D]
FROM #TABLE
PIVOT (
    COUNT(EditType)
    FOR EditType IN ([U], [I], [D])
) AS PIVOTED
Denis Luiz
  • 169
  • 6