Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 Transact-SQL (2000)
 Procedure with output paramter

Author  Topic 

ilimax
Posting Yak Master

164 Posts

Posted - 2006-08-28 : 17:08:20
I am trying to make procedure where I will pull sales in last 30 days for one item....this does not work ...

CREATE PROCEDURE LastThirthySales
@ItemNumco nvarchar(30),
@Quantity float OUTPUT
AS
SET NOCOUNT ON
DECLARE @ItemN nvarchar(30)
SET @ItemN = @ItemNumco
SELECT @Quantity=SUM(Quantity) AS SumQty
FROM arhPOSInvoiceItems
WHERE [Item Number] = @ItemN AND ([Ship Date] BETWEEN GETDATE() - 30 AND GETDATE())
GROUP BY [Item Number]
GO

snSQL
Master Smack Fu Yak Hacker

1837 Posts

Posted - 2006-08-28 : 17:50:37
When you say it doesn't work - what is the problem?

You mustn't group by [Item Number] because you are limiting the results to a single item in the WHERE clause.
Go to Top of Page
   

- Advertisement -