I have a small issue with a stored procedure in SQL Server 2005.
RepInfoID(primary), Date, RepID are the columns in RepInfo
1. 25660, 02/03/2012, 100
2. 25661, 02/03/2012, 100
3. 25662, 02/03/2012, 101
and
RepCID(primary), RepInfoID, Amount are the columns in RepCollection
1. 4343, 25660, 200(money)
2. 4344, 25661, 600
Desired results is:
100(RepID) , 02/03/2012, 800(money)
There can be more than row with the same date.
When a date is selected, foreach RepID on the selected date, I want the sum of Amount on that particular day. I hope I am clear.
Thank you for your help..
CREATE PROCEDURE [dbo].[PracticewithAmount]
(@Date datetime)
AS
BEGIN
Select *
from RepInfo
left outer join RepCollection on RepInfo.RepInfoID = RepCollection.RepInfoID
where RepInfo.Date = @Date
and distinct(RepID)
END
Your question isn’t entirely clear, but here’s what I think you’re saying: