aquí la solucion para este problema
NxSQL ="SELECT gastos, nombre FROM neox Order BY nombre"
Set RS = Server.CreateObject("ADODB.Recordset")
RS.Open NxSQL, oConn,3,1
%>
<table width="720" border="1" cellpadding="0" cellspacing="1">
<tr bgcolor="#FFFFFF">
<td width="50%">Nombre</td>
<td>Gastos</td>
</tr>
<%do while not Rs.eof%>
<tr bgcolor="#FFFFFF">
<%
if Nxx = "" Then
Nxx = Rs("nombre")
else
Nxx = Nxx
end if
%>
<%
if Nxx <> Rs("nombre") Then
%>
<tr bgcolor="#FFFFFF">
<td height="22"><div align="right"><b>Total= </div></td>
<td><b><%=total%> </td>
<%total = ""%>
</tr>
<%
else
end if
%>
<td height="22"><%=RS("nombre")%>
</td>
<td> <%=RS("gastos")%> </td>
<%
if total = "" Then
total = Rs("gastos")
else
valor = Rs("gastos")
total = CINT(total) + CINT(valor)
end If
Nxx = Rs("nombre")
Rs.movenext
loop
%>
<tr bgcolor="#FFFFFF">
<td height="22"><div align="right"><b>Total= </div></td>
<td><b><%=total%> </td>
<%total = ""%>
</table>
<%
RS.Close
Set RS = Nothing
oConn.Close
Set oConn = Nothing
%>
espero sea de aporte