Hi
I need some help working out how I could join the results from a procedure together with a Sum from another table (perhaps it could that be done from within a single procedure?)
This is what I have for the proc with variables
I’d like to show the the results of the above and to include a SUM Column from a many sided related table. The related field to Tblr.rID (above) is Tblc.crID. The field I need to SUM in Tblc is cCost and gouped by crID.
Much appreciated if someone would point me in the right direction.
I need some help working out how I could join the results from a procedure together with a Sum from another table (perhaps it could that be done from within a single procedure?)
This is what I have for the proc with variables
Code:
CREATE PROC [dbo].[CASES]
@Site varchar(100) = NULL
, @Closed varchar(3) = "NO"
as
SET NOCOUNT ON;
if @Site is null
SELECT rID, rSite, rAddress
from Tblr
WHERE rPerson IS NOT NULL AND rClosed = @Closed
Else
SELECT rID, rSite, rAddress
FROM Tblr
WHERE rPerson IS NOT NULL AND rSite = @Site AND rClosd = @Closed
I’d like to show the the results of the above and to include a SUM Column from a many sided related table. The related field to Tblr.rID (above) is Tblc.crID. The field I need to SUM in Tblc is cCost and gouped by crID.
Much appreciated if someone would point me in the right direction.
Last edited: