Ciao a tutti, nella seguente query vorrei inserire, prima del "totale mese" il totale fatto da ciascun collaboratore, ma non so come fare, qualcuno potrebbe aiutarmi ?

[code]
set objRs = objConn.Execute("SELECT Trattamenti.IDTrattamento, Trattamenti.Data, Trattamenti.OraInizio, Trattamenti.Importo, "&Sum&"(Trattamenti.Importo) AS TOTALE, Month(Trattamenti.Data) AS Mese, Year(Trattamenti.Data) AS Anno, [Tipologie Trattamenti].[Descrizione Trattamento] AS Trattamento, Clienti.[Cognome e Nome] AS Cliente, Dipendenti.[Cognome e Nome] AS Dipendente FROM [Tipologie Trattamenti] RIGHT JOIN (Dipendenti RIGHT JOIN (Clienti RIGHT JOIN Trattamenti ON Clienti.IDCliente = Trattamenti.IDCliente) ON Dipendenti.IDImpiegato = Trattamenti.IDImpiegato) ON [Tipologie Trattamenti].[IDTipo Trattamento] = Trattamenti.[IDTipo Trattamento] WHERE Trattamenti.Data>=#"&datainizio&"# AND Trattamenti.Data<=#"&datafine&"# ORDER BY [Trattamenti.Data],Dipendenti.[IDImpiegato] ASC;")
periodo=""
totgen=0
totmese=0
if objRs.EOF then
%>
<table border="1" cellpadding="6" cellspacing="6">
<tr>
<td align="center" style="height:150px; background-color: #FFFFFF"><font size="4">
<p><b><%response.write "Spiacente ma nelle date inserite non risulta eseguito alcun trattamento"%></b></p>
</font>
</td>
</tr>
</table>
<%
else%>
<h3>
<font color="#CC3300" size="6">Resoconto sintetico dal <%=(giornoinizio&"/"&meseinizio&"/"&annoinizio)%> al <%=(giornofine&"/"&mesefine&"/"&annofine)%> - </font></h3>
<hr>
<%
while NOT objRs.EOF
if periodo<>objRs("Mese") then
%>
<table border="1" cellpadding="6" cellspacing="6">
<tr>
<% if periodo="" then
else
%>
<td class="ms-grid8-left" style="background-color: #CCFFFF;visibility:hidden" align="right"><b>
<%
response.write "Totale mese :"
%>
</td>
<td class="ms-grid8-left" style="background-color: #CCFFFF" align="left">
<%
response.write " € "&(formatNumber((totmese),2))
end if %>
</td>
</tr>
<tr height="8"><td colspan="2"></td></tr>
<tr>
<td colspan="2" class="ms-grid8-left" style="background-color: #CCFFFF;width:350;"><b>Mese di : <%=MonthName(Month(objrs("Data")),False)%> - Anno : <%=(Year(objrs("Data")))%></b>
</td>
</tr>
<%
totmese=0
periodo=objrs("Mese")
end if
%>
<%
totmese=totmese+objRs("Importo")
totgen=totgen+objRs("Importo")
objRs.Movenext
wend
%>
<tr>
<td class="ms-grid8-left" style="background-color: #CCFFFF;visibility:hidden" align="right"><b>Totale mese :</td>
<td class="ms-grid8-left" style="background-color: #CCFFFF" align="left">
<% if periodo="" then
else %>
<% response.write " € "&(formatNumber((totmese),2))
end if %>
</b>
</td>
</tr>
<tr height="8"><td colspan="2"></td></tr>
<td class="ms-grid8-left" style="background-color: #CCFFFF" align="right"><b>Totale Generale</b></td>
<td class="ms-grid8-left" style="background-color: #CCFFFF" align="left"><b>
<%=" € "&(formatNumber((totgen),2))%></b>
</td>
</tr>
<%
objRs.Close
Set objRs = Nothing
objConn.Close
end if
Set objConn = Nothing
%>
</table>