find a duplicated name and sum de result

  • Thread starter Thread starter pedro.j.manuel
  • Start date Start date
P

pedro.j.manuel

Hi all,

I have this query.

Select VO.idOperation,G.Description AS Group,VO.Active,
count(VO.idOperation) as tot
from TB_ViaturOperation VO
INNER JOIN TB_Groups AS G ON VO.Group = G.CODGroup
Where VO.idOperation = 10000014
GROUP BY VO.idOperation,G.Description,VO.Active

Result :

idOperation Group Active tot
----------- ------------------------------------------------ ------
-----------
10000014 BEBEDOURO 0 1
10000014 BEBEDOURO 1 1

What i whant is to maque a sum in a tot field when the group name is
duplicate, what i have in a example.
How can i do this

Thanks,

Pedro
 
Hi,
Thanks for your answare
But i need the the VO.Active column to filter the where conditions
that i have, if i make understand.
Like this exemple:

If MacActive = True Then
Filter = " VO.idOperation = " & idOperation & " AND
VO.Active <> 0"
ElseIf MaqDesactiva = True Then
Filter = " VO.idOperation = " & idOperation & " AND
VO.Active = 0"
Else
Filter = " VO.idOperation = " & idOperation & ""
End If

sSQL = "Select VO.idOperation,G.Description AS
Group,VO.Active,count(VO.idOperation) as tot " _
& "from TB_ViatureOperation VO " _
& "INNER JOIN TB_Group AS G ON VO.Group = G.CODGroup " _
& " Where " & Filter & "" _
& " GROUP BY VO.idOperation,G.Description,VO.Active"


KARL DEWEY escreveu:
 
I do not know what you are doing with the code. You ask how to total and I
corrected your query to give total as you can not total and show detail at
the same time unless maybe use DSum.
 
Back
Top