Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

Troubleshooting
Research
Professional Opinions
Ask a Question
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE

troubleshooting Question

SQL INSERT CASE

Avatar of srbenavrbe
srbenavrbe asked on
SQL
13 Comments1 Solution1421 ViewsLast Modified:
* REF_NO  *        ACC  *      AMOUNT1   *       AMOUNT2
******************************************************************
*    1          *            10   *       100,00    *                       *
*    1          *            20   *                      *       110,00     *
*    2          *            30   *       211,00    *                       *
*    3          *            40   *                      *       216,00     *
*    5          *            40   *                      *       216,00     *
*    5          *            50   *       250,00    *                       *
*   5          *             60   *                      *       310,00     *
****************************************************************

Now what I am trying to do is this:Sum the AMOUNT1 or AMOUNT2
depending on the ACC number and send these results
to another table (Table2):

INSERT INTO TABLE2 (a1,a2,a3,a4...)
select
case
sum(if  ACC=10 THEN insert under a1
sum (if ACC=20 THEN insert under a2
and so on...
How do you do it in access?
I was doing it in Delphi:
SUM(CASE WHEN ACC = 10 THEN AMOUNT1 ELSE 0 END)
....
AND REF_NO = k:1;
adoquery1.Parameters.ParamByName('k1').Value := cxDBEdit1;
and it will not work.
How is the queery supposed to be in access??
I am just a beginner so please bear with me.





ASKER CERTIFIED SOLUTION
Avatar of senad
Commented:
This problem has been solved!
Unlock 1 Answer and 13 Comments.
See Answers