problem with access query

  • Thread starter Thread starter Bartlett
  • Start date Start date
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 !
 
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;
 
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.
 
Back
Top