I'm assuming you mean the sum of the amounts. You can do with with xpath like the below
<xsl:template match="/xml">
<xsl:value-of select="sum(test[normalize-space(BookID)='0061AB']/amount)"/>
</xsl:template>
Edit
You can parameterize the BookID by using a variable, or by using a call-template as per my answer to your previous question
The following stylesheet
<xsl:template match="/xml">
<xsl:variable name="bookID" select="'0061AB'"/>
<xsl:value-of select="sum(test[normalize-space(BookID)=$bookID]/amount)"/>
</xsl:template>
Edit #2
It seems that you are now after grouping distinct elements and aggregating the totals.
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" indent="yes"/>
<!-- the identity template -->
<xsl:template match="@* | node()">
<xsl:copy>
<xsl:apply-templates select="@* | node()" />
</xsl:copy>
</xsl:template>
<xsl:template match="test">
<xsl:variable name="bookID" select="normalize-space(BookID/text())" />
<xsl:if test="not(preceding-sibling::test[normalize-space(BookID/text())=$bookID])">
<test>
<xsl:apply-templates />
</test>
</xsl:if>
<!--Else `eat` the duplicate test node-->
</xsl:template>
<xsl:template match="amount">
<amount>
<xsl:variable name="bookID" select="normalize-space(../BookID/text())" />
<xsl:value-of select="sum(//test[normalize-space(BookID/text())=$bookID]/amount)"/>
</amount>
</xsl:template>
</xsl:stylesheet>
Produces the output
<xml>
<test>
<BookID>
0061AB
</BookID>
<amount>18</amount>
</test>
<test>
<BookID>
0062CD
</BookID>
<amount>2</amount>
</test>
</xml>
Please can you take the time to read through the FAQ
Edit 3
This stylesheet will meet your latest requirement.
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" indent="yes" omit-xml-declaration="yes"/>
<!-- the identity template -->
<xsl:template match="@* | node()">
<xsl:copy>
<xsl:apply-templates select="@* | node()" />
</xsl:copy>
</xsl:template>
<xsl:template match="test">
<xsl:variable name="bookID" select="normalize-space(BookID/BookID1/BookID2/text())" />
<xsl:if test="not(preceding-sibling::test[normalize-space(BookID/BookID1/BookID2/text())=$bookID])">
<test>
<xsl:apply-templates />
</test>
</xsl:if>
<!--Else `eat` the duplicate test node-->
</xsl:template>
<xsl:template match="amount">
<amount>
<xsl:variable name="bookID" select="normalize-space(../BookID/BookID1/BookID2/text())" />
<xsl:value-of select="sum(//test[normalize-space(BookID/BookID1/BookID2/text())=$bookID]/amount)"/>
</amount>
</xsl:template>
</xsl:stylesheet>