I have the below code I am trying to subtotal by date
but I am getting the incorrect results I am getting subtotal by each line instead of subtotal by date. Below is an example of the output:
Can someone help me out?
Code:
MySQL = "SELECT ship_id, adrnam, prtnum, early_shpdte, shpsts, cponum, stgdte, host_ordqty, inpqty, stgqty, sum(host_ordqty-stgqty-inpqty) FROM ShipReport (NOLOCK) where (host_ordqty-stgqty-inpqty <> 0) GROUP BY ship_id, adrnam, prtnum, early_shpdte, shpsts, cponum, stgdte, host_ordqty, inpqty, stgqty ORDER BY early_shpdte, ship_id"
FOR MyCursor = LBOUND(MyArray,2) TO UBOUND(MyArray,2)
body = body + "<TR><TD BGCOLOR=""" & SHADE & """>" & MyArray(0,MyCursor) & " </TD><TD WIDTH=300 ALIGN=""CENTER"" BGCOLOR=""" & SHADE & """>" &
MyArray(1,MyCursor) & "</TD><TD BGCOLOR=""" & SHADE & """>" & MyArray(2,MyCursor) & " <TD ALIGN=""RIGHT"" BGCOLOR=""" & SHADE & """>" & MyArray(3,MyCursor) & "</TD><TD ALIGN=""RIGHT"" BGCOLOR=""" & SHADE & """>" & MyArray(4,MyCursor) & "</TD><TD ALIGN=""RIGHT"" BGCOLOR=""" & SHADE & """>" & MyArray(5,MyCursor) & "</TD><TD ALIGN=""CENTER"" BGCOLOR=""" & SHADE & """>" & MyArray(6,MyCursor) & "</TD><TD ALIGN=""CENTER"" BGCOLOR=""" & SHADE & """>" & MyArray(7,MyCursor) & "</TD><TD BGCOLOR=""" & SHADE & """>" & MyArray(8,MyCursor) & " </TD><TD BGCOLOR= """ & SHADE & """>" & MyArray(9,MyCursor) & "
</TD><TD ALIGN=""RIGHT"" BGCOLOR=""" & SHADE & """>" & MyArray(10,MyCursor) & " </TD></TR>" & vbcrlf
IF SHADE = "#FFFFFF" THEN SHADE = "#DDDDDD" ELSE SHADE = "#FFFFFF"
MySQL = "SELECT max(early_shpdte), sum(host_ordqty), sum(inpqty), sum(stgqty) from ShipReport group by early_shpdte"
body = body + "<TR class=""Set0""><td BGCOLOR=""#AAAAAA"" ALIGN=""CENTER"" COLSPAN=7><b>Total:</TD><TD ALIGN=""RIGHT"" BGCOLOR=""#99CC99""><b>" & MyArray(7, MyCursor) & "</TD><TD ALIGN=""RIGHT"" BGCOLOR=""#99CC99""><b>" & MyArray(8, MyCursor) & "</TD><TD ALIGN=""RIGHT"" BGCOLOR=""#99CC99""><b>" & MyArray(9,
MyCursor) & "</TD><TD ALIGN=""RIGHT"" BGCOLOR=""#99CC99""><b>" & MyArray(10, MyCursor) & "</TD></TR>" & vbcrlf
Code:
Order # Customer Location Item Number Ship Date Status Customer PO# Stage Date Qty Ordered Picked Qty Staged Qty
00821 NJ 05300 9/17/2007 Picked 43817 900 765 0
Total: 900 765 0
00837 NY 982328 9/17/2007 Picked 002630906116 36 19 0
Total: 36 19 0
Can someone help me out?