G
Gen
Hi,
I can see a lot of people have posted about this topic, but I couldn't find
anything to help me. I have a query based on four tables:
1. Projects
ProjectID*
2. Purchase Orders
PurchaseOrderID*
ProjectID
OrderDate
3. Order Details
TransactionID*
PurchaseOrderID
ProductID
UnitsOrdered
4. Items
ProductID*
Price/Unit
*Primary key for that table
I'd like to see the total cost we are spending on each project per month and
the number of orders per project were are making. To do that, I have created
the following Query:
PARAMETERS Start DateTime, Finish DateTime;
SELECT Projects.ProjectID, Nz(Count([PurchaseOrderNumber])) AS POCount,
Sum(CCur(Nz([unitsordered]*[Price/unit]))) AS Sub
FROM (Projects LEFT JOIN [Purchase Orders] ON Projects.ProjectNo = [Purchase
Orders].ProjectID) LEFT JOIN (Items RIGHT JOIN [Order Details] ON
Items.ProductID = [Order Details].ProductID) ON [Purchase
Orders].PurchaseOrderID = [Order Details].PurchaseOrderID
WHERE ((([Purchase Orders].OrderDate) Between [start] And [finish]))
GROUP BY Projects.ProjectNo;
This query works great when I don't include the WHERE cause of the date
restriction, but when I do if there were no items ordered for, say, project
1, then nothing is returned, and I'd like it to return $0.00. I read
somewhere that the problem may be that the WHERE statement is preformed
first, so that will eliminate all projects with a zero amount right away.
Can anyone help?
Thanks very much
I can see a lot of people have posted about this topic, but I couldn't find
anything to help me. I have a query based on four tables:
1. Projects
ProjectID*
2. Purchase Orders
PurchaseOrderID*
ProjectID
OrderDate
3. Order Details
TransactionID*
PurchaseOrderID
ProductID
UnitsOrdered
4. Items
ProductID*
Price/Unit
*Primary key for that table
I'd like to see the total cost we are spending on each project per month and
the number of orders per project were are making. To do that, I have created
the following Query:
PARAMETERS Start DateTime, Finish DateTime;
SELECT Projects.ProjectID, Nz(Count([PurchaseOrderNumber])) AS POCount,
Sum(CCur(Nz([unitsordered]*[Price/unit]))) AS Sub
FROM (Projects LEFT JOIN [Purchase Orders] ON Projects.ProjectNo = [Purchase
Orders].ProjectID) LEFT JOIN (Items RIGHT JOIN [Order Details] ON
Items.ProductID = [Order Details].ProductID) ON [Purchase
Orders].PurchaseOrderID = [Order Details].PurchaseOrderID
WHERE ((([Purchase Orders].OrderDate) Between [start] And [finish]))
GROUP BY Projects.ProjectNo;
This query works great when I don't include the WHERE cause of the date
restriction, but when I do if there were no items ordered for, say, project
1, then nothing is returned, and I'd like it to return $0.00. I read
somewhere that the problem may be that the WHERE statement is preformed
first, so that will eliminate all projects with a zero amount right away.
Can anyone help?
Thanks very much