problem with access query

B

Bartlett

Hello,

I have a table with these columns:

idExam idQuestion Result total
===== ======== ===== ====
1 1 ok 12
1 1 ko 3
1 2 ok 15
1 3 ok 6
1 3 ko 9

Is it possible to create a query that return this (I've tried but with
no success...) :

idExam idQuestion ok ko
===== ======== === ====
1 1 12 3
1 2 15 0
1 3 6 9

Thanks in advance for the help !
 
K

KARL DEWEY

Try this --
SELECT Bartlett.idExam, Bartlett.idQuestion,
Sum(IIf([Result]="ok",[total],0)) AS Ok, Sum(IIf([Result]="ko",[total],0)) AS
Ko
FROM Bartlett
GROUP BY Bartlett.idExam, Bartlett.idQuestion;
 
B

Bartlett

KARL said:
Try this --
SELECT Bartlett.idExam, Bartlett.idQuestion,
Sum(IIf([Result]="ok",[total],0)) AS Ok, Sum(IIf([Result]="ko",[total],0)) AS
Ko
FROM Bartlett
GROUP BY Bartlett.idExam, Bartlett.idQuestion;

Thanks Karl, it works.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top