;
WITH
CTE_STC_DETAIL_CODES
AS
(
SELECT
[Code_V_2].[CODE_CAT],
[Code_V_2].[DESCRIPTION]
FROM
[dbo].[STC_Detail]
INNER
JOIN
[STC_Header_V_2]
ON
[STC_Header_V_2].[STCID] = [STC_Detail].[STCID]
[STC_Code]
[STC_Code].[STCDTLID] = [STC_Detail].[STCDTLID]
[Code_V_2]
[Code_V_2].[CodeID] = [STC_Code].[CodeID]
WHERE
[STC_Header_V_2].[STC] =
'33 '
)
[STCDTLID],
[SN]
'Sub Net'
,
[NT]
'Network Indicator'
[CV]
'Coverage Level'
[TQ]
'Time Period Qualifier'
[AI]
'Authorization Indicator'
[CS]
'Cost Share Type'
[IC]
'Insurance Certificate Code'
[QQ]
'Quantity Qualifier Code'
PIVOT
MAX
([DESCRIPTION])
FOR
CODE_CAT
IN
[SN],
[NT],
[CV],
[TQ],
[AI],
[CS],
[IC],
))
Pvt
Naomi N edited Revision 19. Comment: Minor edit
Naomi N edited Revision 18. Comment: Changed first to gold
Naomi N edited Revision 17. Comment: Formatting
Naomi N edited Revision 16. Comment: Formatting
Naomi N edited Revision 15. Comment: Added toc and See Also section
Ed Price - MSFT edited Revision 9. Comment: White space, capitalization, punctuation, tags, and consistent font sizes. Great article!
Ed Price - MSFT edited Revision 10. Comment: Have to revert. An edit messes up the HTML color and code block.
Naomi N edited Revision 8. Comment: Formatting
Naomi N edited Revision 7. Comment: Added See Also
Naomi N edited Revision 5. Comment: Added tag
And I featured it on MSDN blogs as well: blogs.msdn.com/.../t-sql-guru-sql-server-pivot.aspx
Featured on the Wiki Ninjas blog: blogs.technet.com/.../may-t-sql-guru-sql-server-pivot-amp-dynamic-pivot-on-multiple-columns.aspx
Congratulations on being featured on the home page of TechNet Wiki!
social.technet.microsoft.com/wiki
You won twice for May! Congratulations on winning the May TechNet Guru contest! blogs.technet.com/.../technet-guru-awards-may-2013.aspx
Naomi N edited Revision 4. Comment: Adjusted participation link