ok... i have a couple of tables
these are linked by the VendorID.
i also have another table that just stores a beginning and ending date to limit the queries search range.
i am trying to build a report that contains the totals by VendorID of taxable sale, exempt sale, discount, commission, credit card fees and grand total. i have build three seperate queries that contain all of the information i am needing... but i can't figure out how to combine these three queries so that all of the information is in one location so that i can print a report from it.
here is the sql from the queries:
Daily_Sales_tax: the first gets the sum of all the taxable sales amounts, and the discounts and commissions associated with those sales...
Daily_Sales_exempt: the second is the same as the first but tax exempt sales instead of taxable...
Daily_Sales_cc: the third is a total of all the charged amounts and the credit card fees associated...
i tried using the ConsignorNames along with the three queries i just created to create one query that links them all together...
but i realize it is only displaying the vendors that have a hit in the table AND the three queries... i tried reworking it with AND/OR statements instead of all the inner joins... but i still can't get it to work properly.
any help is greatly appreciated!
Code:
Sales(CompanyNo, SaleID, ReceiptID, SaleDate, VendorID, ItemDescription, PaymentType, Amount, Taxable, Discount, SalesTax)
ConsignorNames(VendorID, ConsignorName, ConsignorNo, CommPercent, CCharge)
these are linked by the VendorID.
i also have another table that just stores a beginning and ending date to limit the queries search range.
Code:
SearchSummary(BeginDate, EndDate)
i am trying to build a report that contains the totals by VendorID of taxable sale, exempt sale, discount, commission, credit card fees and grand total. i have build three seperate queries that contain all of the information i am needing... but i can't figure out how to combine these three queries so that all of the information is in one location so that i can print a report from it.
here is the sql from the queries:
Daily_Sales_tax: the first gets the sum of all the taxable sales amounts, and the discounts and commissions associated with those sales...
Code:
SELECT Sales.VendorID, ConsignorNames.ConsignorNo, ConsignorNames.ConsignorName, Sum(Sales.Amount) AS Amount_tax, Sum(Sales.Discount) AS Discount_tax, Sum([Amount]*[CommPercent]) AS Commission_tax
FROM SearchSummary, ConsignorNames INNER JOIN Sales ON ConsignorNames.VendorID = Sales.VendorID
WHERE (((Sales.SaleDate)>[SearchSummary.BeginDate] And (Sales.SaleDate)<[SearchSummary.EndDate]))
GROUP BY Sales.VendorID, ConsignorNames.ConsignorNo, ConsignorNames.ConsignorName, Sales.Taxable
HAVING (((Sales.Taxable)=Yes));
Daily_Sales_exempt: the second is the same as the first but tax exempt sales instead of taxable...
Code:
SELECT Sales.VendorID, ConsignorNames.ConsignorNo, ConsignorNames.ConsignorName, Sum(Sales.Amount) AS Amount_exempt, Sum(Sales.Discount) AS Discount_exempt, Sum([Amount]*[CommPercent]) AS Commission_exempt
FROM SearchSummary, ConsignorNames INNER JOIN Sales ON ConsignorNames.VendorID = Sales.VendorID
WHERE (((Sales.SaleDate)>[SearchSummary.BeginDate] And (Sales.SaleDate)<[SearchSummary.EndDate]))
GROUP BY Sales.VendorID, ConsignorNames.ConsignorNo, ConsignorNames.ConsignorName, Sales.Taxable
HAVING (((Sales.Taxable)=No));
Daily_Sales_cc: the third is a total of all the charged amounts and the credit card fees associated...
Code:
SELECT Sales.VendorID, ConsignorNames.ConsignorNo, ConsignorNames.ConsignorName, Sum(Sales.Amount) AS Amount_cc, Sum(Sales.Discount) AS Discount_cc, Sum(([Amount]-[Discount])*[CCharge]) AS CCFee
FROM SearchSummary, ConsignorNames INNER JOIN Sales ON ConsignorNames.VendorID = Sales.VendorID
WHERE (((Sales.SaleDate)>[SearchSummary.BeginDate] And (Sales.SaleDate)<[SearchSummary.EndDate]) AND ((Sales.PaymentType)="Charge"))
GROUP BY Sales.VendorID, ConsignorNames.ConsignorNo, ConsignorNames.ConsignorName;
i tried using the ConsignorNames along with the three queries i just created to create one query that links them all together...
Code:
SELECT ConsignorNames.ConsignorNo, ConsignorNames.ConsignorName, Daily_Sales_tax.Amount_tax, Daily_Sales_exempt.Amount_exempt, [Discount_tax]+[Discount_exempt] AS Discount, [Commission_tax]+[Commission_exempt] AS Commission, Daily_Sales_cc.CCFee, [Amount_tax]+[Amount_exempt]-([Discount_tax]+[Discount_exempt])-([Commission_tax]+[Commission_exempt])-[CCFee] AS Total
FROM ((ConsignorNames INNER JOIN Daily_Sales_tax ON ConsignorNames.VendorID = Daily_Sales_tax.VendorID) INNER JOIN Daily_Sales_exempt ON ConsignorNames.VendorID = Daily_Sales_exempt.VendorID) INNER JOIN Daily_Sales_cc ON ConsignorNames.VendorID = Daily_Sales_cc.VendorID;
but i realize it is only displaying the vendors that have a hit in the table AND the three queries... i tried reworking it with AND/OR statements instead of all the inner joins... but i still can't get it to work properly.
any help is greatly appreciated!