I have the following query:
It displays the following:
Loc TBP TMam TOsteo TPSA TColo TCholes TTrig THepC TScreens
BTW 1 0 0 0 0 0 0 0 1
BTW 0 0 0 0 2 0 2 1 2
FM 1 0 0 0 0 0 0 0 1
P 1 0 0 1 0 0 0 0 2
SP 2 2 1 0 0 0 0 0 4
SP 0 0 0 0 0 5 0 5 5
I would like it to display:
Loc TBP TMam TOsteo TPSA TColo TCholes TTrig THepC TScreens
BTW 1 0 0 0 2 0 2 1 6
FM 1 0 0 0 0 0 0 0 1
P 1 0 0 1 0 0 0 0 2
SP 2 2 1 0 0 5 0 5 20
So that each location only has one row, and each row is totaled at the end under TScreens.
Any help as to what I am doing wrong is appreciated!!
Thank you!!!
Code:
SELECT tblScr.ScrLoc, Sum(IIf
(tblScr.BP,1,0)) AS ["TBP"], Sum(IIf
(tblScr.Mam,1,0)) AS ["TMam"], Sum(IIf
(tblScr.Osteo,1,0)) AS ["TOsteo"], Sum(IIf(tblScr.PSA,1,0)) AS ["TPSA"], Sum(IIf
(tblScr.Colo,1,0)) AS ["TColo"], Sum(IIf(tblScr.Choles,1,0)) AS ["TCholes"], Sum(IIf(tblScr.Trig,1,0)) AS ["TotalTrig"], Sum(IIf(tblScr.HepC,1,0)) AS ["TotaHepC"], Count(*) AS ["TScreens"]
FROM tblScr
GROUP BY tblScr.ScrLoc, tblScr.ScrD
HAVING (((tblScr.ScrD) Between [Forms]![fdlgOps]![txtStart] And [Forms]![fdlgOps]![txtEnd]));
It displays the following:
Loc TBP TMam TOsteo TPSA TColo TCholes TTrig THepC TScreens
BTW 1 0 0 0 0 0 0 0 1
BTW 0 0 0 0 2 0 2 1 2
FM 1 0 0 0 0 0 0 0 1
P 1 0 0 1 0 0 0 0 2
SP 2 2 1 0 0 0 0 0 4
SP 0 0 0 0 0 5 0 5 5
I would like it to display:
Loc TBP TMam TOsteo TPSA TColo TCholes TTrig THepC TScreens
BTW 1 0 0 0 2 0 2 1 6
FM 1 0 0 0 0 0 0 0 1
P 1 0 0 1 0 0 0 0 2
SP 2 2 1 0 0 5 0 5 20
So that each location only has one row, and each row is totaled at the end under TScreens.
Any help as to what I am doing wrong is appreciated!!
Thank you!!!