开发者

Pivot sql query

开发者 https://www.devze.com 2022-12-16 19:21 出处:网络
I\'ve SQL Server 2005 table COMPETITOR (Id, Title, cDate, Price) I want to format the query so that 开发者_开发知识库its view in Gridview will be like this:

I've SQL Server 2005 table COMPETITOR (Id, Title, cDate, Price) I want to format the query so that 开发者_开发知识库its view in Gridview will be like this:

Pivot sql query

Please help me writing the sql query.


SQL 2005 supports PIVOT - the Books Online doc is http://msdn.microsoft.com/en-us/library/ms177410(SQL.90).aspx

The main shortcoming I've found with the PIVOT stuff is that you must specify the column names, although you can use a query beforehand and inject the values into a varchar variable and then execute that.

0

精彩评论

暂无评论...
验证码 换一张
取 消