I am very new to writing sqls in visual foxpro 9 but have managed to write the script below to provide sales information. This sql works and even dumps the result into Excel, BUT I would like to enter a subtotal of sales and cogs after each product code, while at the same time keeping all the detail of all the individual lines. I have tried to create temporary tables and insert them, to append tables and even create Case, but have not succeeded. Also, as am am just starting out I do not know how to use the reporting side of foxpro as yet so for the time being would like to keep this limited to writing an sql query.
Can someone please spoon feed me?
Thanks in anticipation
Tassman
SELECT qItemSaleLines.ItemID, ;
qItems.ItemID, ;
qItemSaleLines.SaleID, ;
qSales.SaleID, ;
qSales.CardRecordID, ;
qCustomers.CardRecordID, ;
qItems.ItemNumber AS StkCODE, ;
qItems.ItemName AS StkNAME, ;
qCustomers.LastName AS CUSTOMER, ;
qSales.InvoiceNumber AS SaleINVNo, ;
qSales.InvoiceDate AS SaleDATE, ;
qItemSaleLines.Quantity AS SaleQTY, ;
qItemSaleLines.TaxExclusiveTotal AS SaleVALUE, ;
qItemSaleLines.CostOfGoodsSoldAmount AS COGS, ;
qItemSaleLines.TaxExclusiveTotal - qItemSaleLines.CostOfGoodsSoldAmount AS MARGIN, ;
(qItemSaleLines.TaxExclusiveTotal - qItemSaleLines.CostOfGoodsSoldAmount) * 100 / qItemSaleLines.TaxExclusiveTotal AS MPERCENT ;
FROM qItemSaleLines, qItems, qSales, qCustomers ;
WHERE qSales.CardRecordID = qCustomers.CardRecordID ;
AND qItemSaleLines.SaleID = qSales.SaleID ;
AND qItemSaleLines.ItemID = qItems.ItemID ;
AND qSales.InvoiceDate > {^2009-06-30} ;
ORDER BY qItems.ItemNumber, qSales.InvoiceDate ;
INTO TABLE c:\myobfox\ReportTables\TMD\TempReport