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]
AS

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

GO

Open in new window

0
 
Éric MoreauSenior .Net ConsultantCommented:
1
 
Jim HornMicrosoft SQL Server Developer, Architect, and AuthorCommented:
Éric - Nice job on the article.  Well written.
0
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,
Thanks,
0
 
Howard KatzDatabase Report DeveloperAuthor Commented:
Thank you Eric.  That worked perfectly for me.
0
 
Éric MoreauSenior .Net ConsultantCommented:
incorrect comment selected
0
 
Éric MoreauSenior .Net ConsultantCommented:
Howard already said it was working for him!
0
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.