Click here to Skip to main content
15,888,527 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
SQL
@GroupId int, 
	@StartDate DATETIME = NULL, 
	@EndDate DATETIME = NULL,
	@RegionCode varchar(30) = NULL
AS
BEGIN

	
	DECLARE @AgencyTable TABLE (GpoId int, OfcId int,  Total_Bills BIGINT, Bill_Value BIGINT, Commission BIGINT, Total_Amount BIGINT) 

	SET @EndDate = convert(datetime, convert(Varchar(12), @EndDate, 106) + ' 23:59:59PM')

 	
	--1. Billing Summary By GPO Name
	INSERT @AgencyTable (GpoId, OfcId, Total_Bills, Bill_Value, Commission, Total_Amount) 
	SELECT bil.GroupId,  Bil.SubOfficeId , isnull(COUNT(Bil.ConsumerNumber),0) --AS Total_Bills, 
	   ,ISNULL(SUM(Bil.C_Amount),0) --AS Bill_Value, 
	   ,ISNULL(SUM(Bil.Commission),0) --AS Commission, 
	   ,ISNULL(SUM(Bil.C_Amount),0) - ISNULL(SUM(Bil.Commission),0) --AS Total_Amount
    FROM BillTxnSO as Bil inner join pp_offices ofc On bil.GroupId = ofc.Group_Id and bil.SubOfficeId = ofc.OfficeCode  
    Where bil.GroupId = @GroupId AND TransDate  BETWEEN @StartDate AND @EndDate
    Group by bil.GroupId, Bil.SubOfficeId 
    
    --select * from @AgencyTable
	 
	 SELECT   ofc.OfficeName as SubOffice_Name, isnull(gpo.Total_Bills,0)as Total_Bills , isnull(gpo.Bill_Value,0)as Bill_Value , isnull(gpo.Commission,0) as Commission, isnull(gpo.Total_Amount,0) as Total_Amount   
      FROM @AgencyTable gpo 
INNER JOIN pp_offices ofc On ofc.Group_Id = gpo.GpoId and gpo.OfcId  = ofc.OfficeCode 
   ORDER BY  ofc.OfficeName   
   
END
..................................................................................
This Query working fine in report generation but in report viewer i got the SubOffice_Name as it is i.e "SubOffice_Name" in stead of ofc.officeName.Can anyone help me in this regard
Posted
Updated 3-Dec-15 8:04am
v2
Comments
Member 12138525 4-Dec-15 0:50am    
I have done it there is a problem of DataSet

1 solution

I have done it there is a problem of DataSet
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900