This is a standard grouping problem. In XSLT 2.0 it's simply:
<xsl:for-each-group select="//total[@name='date_range']"
group-by="value">
<xsl:for-each select="current-group()">
<tr>
<td><xsl:value-of select="value"/></td>
<td><xsl:value-of select="count"/></td>
</tr>
</xsl:for-each>
<tr>
<td>Total</td>
<td><xsl:value-of select="sum(current-group()/count)"/></td>
</tr>
</xsl:for-each>
If you're stuck with XSLT 1.0 then grouping is much harder, but there's plenty of advice at
http://www.jenitennison.com/xslt/grouping (or in any decent XSLT textbook)
Michael Kay
http://www.saxonica.com/
Author, XSLT Programmer's Reference and XPath 2.0 Programmer's Reference