MichaelaLee
Programmer
Hi All,
I have recently converted a access database to SQL Server 2000. Everything has been going well, but I can't get one query I need to work. I suspect I need to do it another way. I hope You all can help. Here is what I'm trying to do. I have 3 queries, the top level one uses the other two to gather data for the top level query to use. Here they are:
CREATE PROCEDURE [dbo].[nf_TotalsForAllOrders] AS
SELECT DISTINCT nf_ShowProducts.ProgramName, nf_ShowProducts.ProductName, nf_SubTotalItems.SumOfQuantity,
nf_ShowProducts.OrderDate
FROM nf_ShowProducts INNER JOIN nf_SubTotalItems ON nf_ShowProducts.ProductID= nf_SubTotalItems.ProductID
ORDER BY nf_ShowProducts.ProgramName
GO
CREATE PROCEDURE [dbo].[nf_ShowProducts] AS
SELECT Programs.ProgramID, Programs.ProgramName, Orders.OrderID, Orders.ProgramID, Orders.OrderDate,
OrderDetail.Quantity, OrderDetail.ProductID, Products.ProductName
FROM ((Programs INNER JOIN Orders ON Programs.ProgramID = Orders.ProgramID) INNER JOIN OrderDetail
ON Orders.OrderID = OrderDetail.OrderID) INNER JOIN Products ON OrderDetail.ProductID = Products.ProductID;
GO
CREATE PROCEDURE [dbo].[nf_SubTotalItems] AS
SELECT Products.ProductID, Sum(OrderDetail.Quantity) AS SumOfQuantity
FROM OrderDetail INNER JOIN Products ON OrderDetail.ProductID=Products.ProductID
GROUP BY Products.ProductID
GO
Is it possible to do this in SQL Server 2000. Thanks for any help possible.
Michael Lee
I have recently converted a access database to SQL Server 2000. Everything has been going well, but I can't get one query I need to work. I suspect I need to do it another way. I hope You all can help. Here is what I'm trying to do. I have 3 queries, the top level one uses the other two to gather data for the top level query to use. Here they are:
CREATE PROCEDURE [dbo].[nf_TotalsForAllOrders] AS
SELECT DISTINCT nf_ShowProducts.ProgramName, nf_ShowProducts.ProductName, nf_SubTotalItems.SumOfQuantity,
nf_ShowProducts.OrderDate
FROM nf_ShowProducts INNER JOIN nf_SubTotalItems ON nf_ShowProducts.ProductID= nf_SubTotalItems.ProductID
ORDER BY nf_ShowProducts.ProgramName
GO
CREATE PROCEDURE [dbo].[nf_ShowProducts] AS
SELECT Programs.ProgramID, Programs.ProgramName, Orders.OrderID, Orders.ProgramID, Orders.OrderDate,
OrderDetail.Quantity, OrderDetail.ProductID, Products.ProductName
FROM ((Programs INNER JOIN Orders ON Programs.ProgramID = Orders.ProgramID) INNER JOIN OrderDetail
ON Orders.OrderID = OrderDetail.OrderID) INNER JOIN Products ON OrderDetail.ProductID = Products.ProductID;
GO
CREATE PROCEDURE [dbo].[nf_SubTotalItems] AS
SELECT Products.ProductID, Sum(OrderDetail.Quantity) AS SumOfQuantity
FROM OrderDetail INNER JOIN Products ON OrderDetail.ProductID=Products.ProductID
GROUP BY Products.ProductID
GO
Is it possible to do this in SQL Server 2000. Thanks for any help possible.
Michael Lee