Andrea
Andrea

Reputation: 1

summing values from one table into another table

I'm an SQL newbie using VB6/Access 2000 and am trying to get a query which puts the sum of values from a table into another table. VB6 does the job, but it's so slow. I searched and tried in Access many times, just got lost with keywords IN, ON, (INNER) JOIN, each time getting a different error.

The core code should be as follows:

update t1
set t1.value = sum(t2.value)
where
val(t2.code)>89
and
t2.date=t1.date

After further searching i found a similar question here ( http://goo.gl/uqlw0U ) and tried that:

UPDATE t1
SET t1.value = 
    (
SELECT 
    SUM(t2.value) 
FROM spese
    WHERE
     t1.date=t2.date
AND
    val(t2.code)>89
    )

but Access just says "updatable query needed" -- what does that mean?

Upvotes: 0

Views: 202

Answers (1)

Vlado
Vlado

Reputation: 878

Try this:

UPDATE t1
 SET t1.value = SUM(t2.value)
FROM t1, t2
WHERE
 val(t2.code)>89
AND
 t2.date=t1.date

Upvotes: 0

Related Questions