PLease, read my comment to the question. I'm not sure what you want, but my advice is to create
stored procedure[
^](SP) like this:
CREATE PROCEDURE GetAmountRangeDates
@dateFrom DATETIME,
@dateTo DATETIME
AS
BEGIN
SELECT PM.PID, PM.Pname, TM.TYpe, SUM(TM.Amount) AS Amount
FROM Pmaster AS PM LEFT JOIN Tmaster AS TM O PM.PID=TM.PID
WHERE TM.[Date of Transaction] BETWEEN @dateFrom AND @dateTo
GROUP BY PM.PID, PM.Pname, TM.TYpe
END
Above SP gets 2 input parameters:
@dateFrom
and
@dateTo
. Use both to define date range.
How to use sp in code?
How to: Execute a Stored Procedure that Returns Rows[
^]
How to call SQL Server stored procedures in ASP.NET by using Visual Basic .NET [
^]