how to convert row to column in SQL

前端 未结 3 1522
北荒
北荒 2021-01-23 20:05

Can somebody help me with this SQL Query.

In the following table, RESPONSES counts how many times SEGMENT has responded on CHECKED date.

CREATE TABLE #         


        
3条回答
  •  生来不讨喜
    2021-01-23 20:30

    You need to use dynamic SQL. See this blog post for an example. Another example, different blog, same approach.

    If your columns are static and you're using SQL Server 2005 and higher you can use the PIVOT feature to perform this type of query.

提交回复
热议问题