Create View with PIVOT operator

I would like a sample script of using the Pivot operator in a View in T-sql
Howard KatzDatabase Report DeveloperAsked:
Who is Participating?
Éric MoreauConnect With a Mentor Senior .Net ConsultantCommented:
Unless your pivot as to be dynamic, just add the query of your pivot into a view like you would do for any other query!

CREATE VIEW [dbo].[View_1]

  FROM (
	SELECT Computer FROM   dbo.CrashPlanStatus
) AS Source
  PIVOT (COUNT(Computer) FOR Computer IN ([FGLDC04], [FGLDC05], [FGLDC06])) AS Pivoted


Open in new window

Éric MoreauSenior .Net ConsultantCommented:
Jim HornMicrosoft SQL Server Developer, Architect, and AuthorCommented:
Éric - Nice job on the article.  Well written.
Cloud Class® Course: Python 3 Fundamentals

This course will teach participants about installing and configuring Python, syntax, importing, statements, types, strings, booleans, files, lists, tuples, comprehensions, functions, and classes.

Howard KatzDatabase Report DeveloperAuthor Commented:
I agree that article was clear and well written, but I was asking how to create a View with a PIVOT operator in the view,
Howard KatzDatabase Report DeveloperAuthor Commented:
Thank you Eric.  That worked perfectly for me.
Éric MoreauSenior .Net ConsultantCommented:
incorrect comment selected
Éric MoreauSenior .Net ConsultantCommented:
Howard already said it was working for him!
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.