Hi
I wanna write a proc that returns Distinct CustomerID's in a table and returns result in output parameter
When i try this, i get error - incorrect syntax near distinct. Any ideas??
ALTER PROCEDURE proc_Report_CountCustomers_Sept
(
@.CustCount int OUTPUT
)
AS
SET NOCOUNT ON
select
@.CustCount = distinct(CustomerID)
from
Orders
Where
OrderDate > '2006-09-01' and OrderDate < '2006-10-01'
hi,
what you want to return, count of distinct ids or distinct ids itself ?
regards,
satish
|||hehe.. er ofcourse. I wanted to count the distinct ids, but i didnt count
i worked it out
cheers brother
ALTER PROCEDURE proc_Report_CountCustomers_Sept
(
@.CustCount int OUTPUT
)
AS
SET NOCOUNT ON
SELECT
@.CustCount =Count(DISTINCT(CustomerID))
FROM
Orders
WHERE
OrderDate > '2006-09-01' and OrderDate < '2006-10-01'
good you got it working :),
cheers ,
satish
No comments:
Post a Comment