Click here to Skip to main content
15,903,388 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
In this query my SP doing right way for forword data proccessing when calculate the bill of next year.......i.e. your bill from 2010....calculate data bill for right way..2011,same for 2012,2013....so on...but problem are arise when .....show the data in 2009....(Backword)
means 2009 have not data then not show the data but here show data......sorry for bad english

SQL
ALTER PROCEDURE [dbo].[spGetMaxBillingFinancialYearID]      
 @FinancialYearID INT,      
 @WardNoID INT,
 @MohallaID INT,      
 @MaxBillingFinancialYearID INT OUTPUT      
AS       

BEGIN      
 IF EXISTS(SELECT FinancialYearID FROM PropertyTaxBill WHERE WardNoID=@WardNoID AND MohallaID=@MohallaID AND FinancialYearID < @FinancialYearID) 

    
 BEGIN      
  SET @MaxBillingFinancialYearID=(SELECT TOP 1 FinancialYearID FROM PropertyTaxBill WHERE WardNoID=@WardNoID AND MohallaID=@MohallaID        
						AND FinancialYearID =(SELECT MAX(FinancialYearID) FROM PropertyTaxBill WHERE WardNoID=@WardNoID AND MohallaID=@MohallaID        
						AND FinancialYearID < @FinancialYearID))

					  
END      
 ELSE      
 BEGIN      
  SET @MaxBillingFinancialYearID=0      
 END 
END
Posted
Updated 20-Feb-13 18:51pm
v2
Comments
Sergey Alexandrovich Kryukov 21-Feb-13 0:43am    
Where is .NET here?
—SA

1 solution

Hi
Please change below condition
SQL
IF EXISTS(SELECT FinancialYearID FROM PropertyTaxBill WHERE WardNoID=@WardNoID AND MohallaID=@MohallaID AND FinancialYearID < @FinancialYearID) 
To

IF EXISTS(SELECT FinancialYearID FROM PropertyTaxBill WHERE WardNoID=@WardNoID AND MohallaID=@MohallaID AND FinancialYearID <= @FinancialYearID)
 
Share this answer
 
v2
Comments
uspatel 21-Feb-13 0:54am    
Always add code tag in your solution for code text to make it more understandable.

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