, Guest>> || || |
/ Microsoft SQL Server
 TRANSFORM - .  [new]

Member

:
: 129
:

client card_type card_num saldo
---------- ----------- --------------- ---------------------
_01 110 _01 0.00
_01 100 _01 100.90
_01 105 _01 0.00
_01 106 _01 0.00
_01 112 _01 0.00
_02 110 _02 300000.00
_02 100 _02 959.99
_02 105 _02 0.00
_02 107 _02 0.00
_02 113 _02 0.00
_03 110 _03 43500.00
_03 100 _03 13689.05
_03 105 _03 0.00
_03 107 _03 0.00
_01 110 _04 42714.63
_01 100 _04 0.00
_01 105 _04 -785.37
_01 107 _04 -0.48
_04 110 _05 30026.52
_04 100 _05 0.00
_04 105 _05 -2573.48
_04 113 _05 0.00
_04 107 _05 0.00
_05 110 _06 195653.32
_05 111 _06 0.00
_05 100 _06 0.00
_05 105 _06 -104346.68
_05 112 _06 60652.53
_05 106 _06 32347.47
_05 107 _06 -219.16
_05 113 _06 0.00
_05 114 _06 0.00
_05 119 _06 67.94
_06 110 _07 5000.00
_06 100 _07 18.75
_06 105 _07 0.00
_06 112 _07 81701.75
_06 106 _07 0.00
_06 107 _07 0.00
_06 119 _07 0.00

:

declare @t table (client varchar(10), card_type int,card_num varchar(15),saldo money)	

insert into @t values ('_01',110,'_01',0.00)
insert into @t values ('_01',100,'_01',100.90)
insert into @t values ('_01',105,'_01',0.00)
insert into @t values ('_01',106,'_01',0.00)
insert into @t values ('_01',112,'_01',0.00)
insert into @t values ('_02',110,'_02',300000.00)
insert into @t values ('_02',100,'_02',959.99)
insert into @t values ('_02',105,'_02',0.00)
insert into @t values ('_02',107,'_02',0.00)
insert into @t values ('_02',113,'_02',0.00)
insert into @t values ('_03',110,'_03',43500.00)
insert into @t values ('_03',100,'_03',13689.05)
insert into @t values ('_03',105,'_03',0.00)
insert into @t values ('_03',107,'_03',0.00)
insert into @t values ('_01',110,'_04',42714.63)
insert into @t values ('_01',100,'_04',0.00)
insert into @t values ('_01',105,'_04',-785.37)
insert into @t values ('_01',107,'_04',-0.48)
insert into @t values ('_04',110,'_05',30026.52)
insert into @t values ('_04',100,'_05',0.00)
insert into @t values ('_04',105,'_05',-2573.48)
insert into @t values ('_04',113,'_05',0.00)
insert into @t values ('_04',107,'_05',0.00)
insert into @t values ('_05',110,'_06',195653.32)
insert into @t values ('_05',111,'_06',0.00)
insert into @t values ('_05',100,'_06',0.00)
insert into @t values ('_05',105,'_06',-104346.68)
insert into @t values ('_05',112,'_06',60652.53)
insert into @t values ('_05',106,'_06',32347.47)
insert into @t values ('_05',107,'_06',-219.16)
insert into @t values ('_05',113,'_06',0.00)
insert into @t values ('_05',114,'_06',0.00)
insert into @t values ('_05',119,'_06',67.94)
insert into @t values ('_06',110,'_07',5000.00)
insert into @t values ('_06',100,'_07',18.75)
insert into @t values ('_06',105,'_07',0.00)
insert into @t values ('_06',112,'_07',81701.75)
insert into @t values ('_06',106,'_07',0.00)
insert into @t values ('_06',107,'_07',0.00)
insert into @t values ('_06',119,'_07',0.00)


:

100105106107110111112113114119
_01_01 100.9000000000
_01_04 0-785.370-0.4842714.6300000
_02_02 959.9900030000000000
_03_03 13689.050004350000000
_04_05 0-2573.480030026.5200000
_05_06 0-104346.6832347.47-219.16195653.32060652.530067.94
_06_07 18.750005000081701.75000


MS SQL Server 2008?
18 13, 16:22[15149448]      |
 Re: TRANSFORM - .  [new]
10
Guest
10
10
18 13, 16:26[15149496]      |
 Re: TRANSFORM - .  [new]

Member

:
: 129
10
10
10


?!
18 13, 16:30[15149536]      |
 Re: TRANSFORM - .  [new]

Member

:
: 129
10 ,

. .
18 13, 16:33[15149565]      |
 Re: TRANSFORM - .  [new]
333
Member

:
: 3683
select client, card_num, isnull([100], 0) as [100], isnull([105], 0) as [105], isnull([106], 0) as [106] --    
from @t t
     pivot (sum(saldo) for card_type in ([100], [105], [106], [107], [110], [111], [112], [113], [114], [119] )) x
order by client, card_num
18 13, 16:39[15149604]      |
 Re: TRANSFORM - .  [new]

Member

:
: 129
333
select client, card_num, isnull([100], 0) as [100], isnull([105], 0) as [105], isnull([106], 0) as [106] --    
from @t t
     pivot (sum(saldo) for card_type in ([100], [105], [106], [107], [110], [111], [112], [113], [114], [119] )) x
order by client, card_num


?! .
18 13, 16:40[15149617]      |
 Re: TRANSFORM - .  [new]
wizli
Member

: Minsk
: 270
. , , . " 10 ".
18 13, 16:42[15149632]      |
 Re: TRANSFORM - .  [new]

Member

:
: 129
wizli,
, . . 333 PIVOT , , 100, 105, 106, 107 .., .
18 13, 16:47[15149682]      |
 Re: TRANSFORM - .  [new]
wizli
Member

: Minsk
: 270
,

" 10
10"
[url=]https://www.sql.ru/faq/faq_topic.aspx?fid=358[/url]
Pivot' , .
18 13, 16:50[15149713]      |
 Re: TRANSFORM - .  [new]
333
Member

:
: 3683
?! .

STFF pivot
18 13, 16:50[15149720]      |
 Re: TRANSFORM - .  [new]

Member

:
: 129
.
18 13, 17:01[15149835]      |
 Re: TRANSFORM - .  [new]
iap
Member

:
: 47142
, .
.
- ? :))
18 13, 17:52[15150186]      |
 Re: TRANSFORM - .  [new]

Member

:
: 129
iap, ? ?
19 13, 07:13[15152107]      |
/ Microsoft SQL Server