How do i get the grand total of the NANDCOST + LOGGERCOST + SECURITY COST
My code.
<body>
<form id="form1" runat="server">
<div>
<table align="center" border="1px" style="width: 811px">
<tr>
<td align="center" class="style4"
style="font-size: large; color: #006699; font-family: Cambria; font-weight: bold;">
<table style="width: 100%; height: 7px; color: #FFFFFF; background-color: #000099;"
bgcolor="#0066CC">
<tr>
<td style="background-color: #336699" class="style5" align="right">
<asp:LinkButton ID="LinkButton2" runat="server" ForeColor="White"
PostBackUrl="H1.aspx">Home</asp:LinkButton>
| <asp:LinkButton
ID="LinkButton1" runat="server" ForeColor="White"
PostBackUrl="Lgin.aspx" OnClick="LinkButton1_Click">Sign out</asp:LinkButton>
</td>
</tr>
</table>
<br />
<br />
<br />
<br />
<br />
REPORT FOR ALL WORK TICKET CATEGORY FROM
<asp:Label ID="Label112" runat="server"></asp:Label>
TO
<asp:Label ID="Label113" runat="server"></asp:Label>
<br />
<br />
<br />
<br />
<br />
<table border='1'
style="width: 1012px; font-family: Cambria; font-size: 15px; font-size: smal1; font-weight: normal;">
<tr>
<td class="style8">S/N</td>
<td class="style9">QUERYDATE</td>
<td class="style19">NAND</td>
<td class="style20">
<b>COST </b> </td>
<td class="style19">LOGGER</td>
<td class="style20">
<b>COST </b> </td>
<td class="style19">SECURITY</td>
<td class="style20">
<b>COST </b> </td>
</tr>
<%
// SqlCommand scz = new SqlCommand("SELECT DATENAME(dw, Time1)+', '+CONVERT(VARCHAR(12), Time1, 107) as Query_Date, COUNT(Exact) AS NAMPAK,Exact = SUM(Exact),N_MCOST = SUM(Exact) * MAX(Value)
FROM
MealLog WHERE Company = 'NAMPAK' GROUP BY Time1 ORDER BY Time1 ASC ", dbConn);;
SqlCommand scz = new SqlCommand("DECLARE @DynamicPivotQuery AS NVARCHAR(MAX) SET @DynamicPivotQuery =N';WITH cte AS (SELECT ROW_NUMBER() OVER(ORDER BY (SELECT 0)) ''S/N'', Datename(dw, Time1)+'', '' + CONVERT(VARCHAR(12), Time1, 107) QUERYDATE, NAND, NAND * (SELECT TOP 1 Value FROM [MealLog] WHERE Company = ''NAND'') NANDCOST,LOGGER, LOGGER * (SELECT TOP 1 Value FROM [MealLog] WHERE Company = ''LOGGER'') LOGGERCOST,SECURITY, SECURITY * (SELECT TOP 1 Value FROM [MealLog] WHERE Company = ''SECURITY'') SECURITYCOST FROM (SELECT Time1,Exact,Company from MealLog) t pivot ( MAX(Exact) FOR Company IN ([LOGGER],[NAND],[SECURITY])) piv) SELECT CAST([S/N] AS VARCHAR(10)) [S/N],QUERYDATE,NAND,NANDCOST,LOGGER,LOGGERCOST,SECURITY,SECURITYCOST FROM cte UNION SELECT ''TOTAL'','''',SUM(CAST(NAND AS BIGINT)),SUM(CAST(NANDCOST AS BIGINT)),SUM(CAST(LOGGER AS BIGINT)),SUM(CAST(LOGGERCOST AS BIGINT)),SUM(CAST(SECURITY AS BIGINT)),SUM(CAST(SECURITYCOST AS BIGINT)) FROM cte' EXEC (@DynamicPivotQuery) ", dbConn);
scz.CommandType = CommandType.Text;
dbConn.Open();
SqlDataReader sdz = scz.ExecuteReader();
int ct = 1;
while (sdz.Read())
{
Response.Write("<tr style><td class='style2'>" + ct + "</td><td class='style2'>" + sdz["QUERYDATE"].ToString() + "</td><td class='style5'>" + sdz["NAND"].ToString() + "</td><td class='style5'>" + "₦" + sdz["NANDCOST"].ToString() + "</td> <td class='style5'>" + sdz["LOGGER"].ToString() + "</td><td class='style5'>" + "₦" + sdz["LOGGERCOST"].ToString() + "</td><td class='style5'>" + sdz["SECURITY"].ToString() + "</td><td class='style5'>" + "₦" + sdz["SECURITYCOST"].ToString() + "</td></tr>");
ct++;
}
dbConn.Close();%>
<tr style="font-size: small; font-weight: normal; font-style: normal; font-family: Arial, Helvetica, sans-serif">
<td class="style22"></td>
<td class="style23">Total</td>
<td class="style6">
<asp:Label ID="Label2"
runat="server" Font-Bold="True" ForeColor="#3366CC"></asp:Label>
</td>
<td class="style21">
<asp:Label ID="Label1"
runat="server" Font-Bold="True" ForeColor="#3366CC"></asp:Label>
</td>
<td class="style13">
<asp:Label ID="Label3"
runat="server" Font-Bold="True" ForeColor="#3366CC"></asp:Label>
</td>
<td class="style22">
<asp:Label ID="Label4"
runat="server" Font-Bold="True" ForeColor="#3366CC"></asp:Label>
</td>
<td class="style22">
<asp:Label ID="Label7"
runat="server" ForeColor="#3366CC" Font-Bold="True"></asp:Label>
</td>
<td class="style21">
<asp:Label ID="Label8"
runat="server" ForeColor="#3366CC" Font-Bold="True"></asp:Label>
</td>
</tr>
</table>
<asp:Label ID="LabelF"
runat="server" ForeColor="#3366CC"></asp:Label>
<br />
<asp:Label ID="Label60" runat="server" ForeColor="#3366CC"></asp:Label>
<table border="1" style="width: 100%;">
<tr>
<td class="style16">GRAND TOTAL FOR NANDCOST+LOGGERCOST+SECURITYCOST</td>
<td class="style15">₦<asp:Label ID="Label114" runat="server" Font-Bold="True" Font-Size="Large"></asp:Label>
</td>
</tr>
</table>
</td>
</tr>
</table>
</div>
</form>
</body>
Please help