0
我具有以下表到行動態柱SQL
CREATE TABLE [dbo].[PC_Adjustments](
[Property_Adjustment_id] [int] IDENTITY(1,1) NOT NULL,
[property_id] [numeric](18, 0) NOT NULL,
[Adjustment_amount] [decimal](18, 2) NULL,
[Adjustment_Desc] [nvarchar](2000) NULL
) ON [PRIMARY]
insert into PC_Adjustments values(12,2.3,'test1')
insert into PC_Adjustments values(12,4.3,'test2')
insert into PC_Adjustments values(12,4.3,'test3')
insert into PC_Adjustments values(12,6.3,'test4')
insert into PC_Adjustments values(13,2.3,'test31')
insert into PC_Adjustments values(13,2.3,'testd1')
insert into PC_Adjustments values(13,2.3,'test41')
insert into PC_Adjustments values(14,2.3,'test561')
在上述情況下爲具有4行PROPERTY_ID 12,13具有3其可以增加或decrese.what我的意思是說是其動態行。
我需要以下輸出。
property_id Adjustment_1 Amount Adjustment_2 Amount Adjustment_3 Amount Adjustment_4 Amount
12 test1 2.3 test2 4.3 test3 4.3 test4 6.3
13 test31 2.3 testd1 2.3 test41 2.3 NULL NULL
14 test561 2.3 NULL NULL NULL NULL NULL NULL
我使用MSSQL 2008年
看看Pivot表 - http://technet.microsoft.com/en-us/library/ms177410(v=sql.105).aspx –
當你輸入標題時,你沒看到類似的帖子嗎?我敢肯定,有一百萬重複.. –
是否有任何posible使用樞軸 – Sree