Append query + sum ?

sasolini

Registered User.
Local time
Today, 17:59
Joined
Dec 27, 2004
Messages
61
hello,

i have 3 tables:

ACAD_U:
ID
PROIZ_A
TIP_A
DN_A
KOS_A

IN_U:
ID
PROIZ_I
TIP_I
DN_I
KOS_I

ZALGA:
ID
PROIZ_Z
TIP_Z
DN_Z
KOS_A
KOS_I
KOS_Z


Now i want to create an append query that will add in table ZALGA fealds PROIZ_I, TIP_I, DN_I, KOS_A, KOS_I by critera if TIP_A = TIP_I AND DN_A = DN_I then calculate KOS_Z = KOS_I - KOS_A?

Can someone pls tell me how to do that?

THX
 
You can't use an append query to add new columns to a table. You need to do that through the GUI or by updating the tabledef with DAO or ADO.

Append queries add rows to tables.
Update queries update specific columns in existing rows.
 
Perhaps this is what you are looking for:

INSERT INTO ZALGA ( ID, PROIZ_Z, TIP_Z, DN_Z, KOS_A, KOS_I, KOS_Z )
SELECT ACAD_U.ID, IN_U.PROIZ_I, IN_U.TIP_I, IN_U.DN_I, ACAD_U.KOS_A, IN_U.KOS_I, [KOS_I]-[KOS_A] AS TheSum
FROM ACAD_U INNER JOIN IN_U ON (ACAD_U.DN_A = IN_U.DN_I) AND (ACAD_U.ID = IN_U.ID)
 

Users who are viewing this thread

Back
Top Bottom