Hola, prueba así
Código PHP:
set rs1 = Server.CreateObject("ADODB.Recordset")
SQL = "Select distinct referencias, color from tabla"
rs1.Open SQL, oConn,3,1
do while not rs1.eof
%>
<%=rs1("referencias")%> - <%=rs1("color")%>:
<%
set rs2 = Server.CreateObject("ADODB.Recordset")
otra consulta ya sin registros repetidos
SQL = "Select referencias, ref1, ref2, ref3, ref4 from tabla where referencias = "& CInt(rs1("referencias")) &""
rs2.Open SQL, oConn,3,1
Totalref1 = 0
Totalref2 = 0
Totalref3 = 0
Totalref4 = 0
do while not rs2.eof
Totalref1 = Totalref1 + rs2("ref1")
Totalref2 = Totalref2 + rs2("ref2")
Totalref3 = Totalref3 + rs2("ref3")
Totalref4 = Totalref4 + rs2("ref4")
rs2.Movenext
loop
%>
<%=Totalref1%> - <%=Totalref2%> - <%=Totalref3%> - <%=Totalref4%><br />
<%
rs2.Close
set rs2=nothing
rs1.Movenext
loop
rs1.Close
set rs1=nothing
oConn.Close
set oConn=nothing
Suerte