I have a table with the following fields; TranID, Date, Type, Account, Amount.
I pull a list of Accounts (Companies) with:
SELECT Distinct Account FROM Table
I've also got a Stored procedure:
CREATE PROCEDURE Procedure
@supplier varchar(3),
@type varchar(2),
@datefrom varchar(8),
@dateto varchar(8)
AS
(Select sum(Amount) from Table WHERE Account=@supplier and Type=@type and Date>=@datefrom and Date<=@dateto)
GO
Which gives me a sum of Invoices for a particular Account, with a certain date range.
What I'm after is a stored proc that will return a table of account and sum. Can anyone point me in the right direction?
Thanks
Ben
I pull a list of Accounts (Companies) with:
SELECT Distinct Account FROM Table
I've also got a Stored procedure:
CREATE PROCEDURE Procedure
@supplier varchar(3),
@type varchar(2),
@datefrom varchar(8),
@dateto varchar(8)
AS
(Select sum(Amount) from Table WHERE Account=@supplier and Type=@type and Date>=@datefrom and Date<=@dateto)
GO
Which gives me a sum of Invoices for a particular Account, with a certain date range.
What I'm after is a stored proc that will return a table of account and sum. Can anyone point me in the right direction?
Thanks
Ben