July 25, 2005 at 3:21 pm
hi need help
how can i update field in Table
only if exist
like this
-------------------------------------------------------------
my table is like this
Outo_Number | ID | int_product | total_product
| after_sum
1 | 1025 | 38 | 30 0
2 | 1025 | 39 | 45 0
3 |1025 | 38 | 99 0
4 | 1026 | 38 | 30 0
5 | 1026 | 39 | 70 0
6 | 1026 | 38 | 55 0
7 | 1026 | 39 | 79 0
---------------------------------------------------------
only if
like this
39-------------##################
declare @id
declare @total_1
set @id =1
if exist
select from table product
where id=@id and int_product =39
then
Select SUM(total_product) as @total_1
where id=@id and int_product =39
update table product
set [after_sum]=@total_1
where id=@id and int_product =39
40 -------------------------############3
declare @total_2
set @id =1
if exist
select from table product
where id=@id and int_product =40
then
Select SUM(total_product) as @total_2
where id=@id and int_product =40
update table product
set [after_sum]=@total_2
where id=@id and int_product =40
-------------------------
thnks
ilan
July 25, 2005 at 3:50 pm
Not sure if after_total is a running sum or not but here is my first guess:
Update P
Set [after_sum]= A.Tot
From
product P
join
( select id, int_Product, sum(total_Product) as Tot
from Product
group by id, int_Product) A
on A.id = P.Id and A.int_product =P.int_Product
* Noel
July 28, 2005 at 1:10 am
hi
can i get help on my Stord procedures ??????????
thnks
ilan
Viewing 3 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply