|
Posted by Madhivanan on 12/29/07 08:52
On Dec 29, 12:11 pm, "info" <informatyk@fitness[CUT]authority.pl>
wrote:
> Hi,
>
> I have one table name: art
>
> column:
>
> symbol_art price1 price2
> ----------- ------- -------
> AG-0001 20 40
> AG-0001S null null
> AG-0002 40 60
> AG-0002S null null
> ...
> How paste in null price1 and price2 from oryginal symbol_art AG-0001,AG-0002 ?
> (duplicate symbol_art %-%'S ' it's always the same for oryginal symbol_art)
>
> thanks for any help
> Tom
declare @t table(symbol_art varchar(100), price1 int,price2 int)
insert into @t
select 'AG-0001', 20, 40 union all
select 'AG-0001S', null, null union all
select 'AG-0002', 40 , 60 union all
select 'AG-0002S', null , null
update t1
set price1=t2.price1,
price2=t2.price2
from @t t1 inner join
(
select symbol_art,price1,price2 from @t where price1 is not null and
price2 is not null
) as t2
on t1.symbol_art like t2.symbol_art+'%'
where t1.price1 is null and t1.price2 is null
select * from @t
Navigation:
[Reply to this message]
|