-
Aug 29th, 2014, 01:52 AM
#1
Thread Starter
PowerPoster
update record with summ
table SOMME
AG DATA DIFF MASTRO POSIZ DCI
100 26/08/2014 10 20 10 111
100 26/08/2014 20 10 20 111/8
200 26/08/2014 10 20 10 111
table CASSA (result before query)
AG DATA DIFF MASTRO POSIZ
100 26/08/2014 0 0 0
200 26/08/2014 0 0 0
table CASSA (result after query)
AG DATA DIFF MASTRO POSIZ
100 26/08/2014 30 30 30
200 26/08/2014 10 20 10
I need, with a Join AG and DATA, to update the table CASSA with a summ of DIFF, MASTRO, and POSIZ but only if in DCI of SOMME is present 1118 and 1119/8, how to with a sql?
Tks.
Note:
in CASSA not possible duplicate AG and DATA
in DCI of SOMME i can have only two vlue 1118 or 1119/8
Last edited by luca90; Sep 1st, 2014 at 02:27 AM.
-
Aug 29th, 2014, 11:33 AM
#2
Re: update record with summ
maybe something like this:
Code:
update cassa
set diff=sumdiff,mastro=summastro,posiz=sumposiz
from cassa inner join (
select ag,data,sum(diff) sumdiff,sum(mastro) summastro,sum(posiz) sumposiz
from somme
where not dci is null
group by ag,data
) T1 on T1.ag=cassa.ag and T1.data=cassa.data
totally untested
-
Sep 1st, 2014, 04:15 PM
#3
Thread Starter
PowerPoster
Re: update record with summ
-
Sep 2nd, 2014, 04:08 AM
#4
Re: update record with summ
Originally Posted by luca90
TKS...but syntiax error
1. What database system are you using?
2. What is the error message?
3. What have you tried to fix it?
Please answer all three questions to get help
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|