Hello DBA's once again I needed help.
I have this query which will give me the sum of all sold insurance.
- select e.AgentID, sum(isnull(e.TotalPremium,0)) from tblMotorInsurance_eCI e where e.AgentID=@AgentID group by e.AgentID;
I give me the answer I needed if the agent has a sale. but if the agent doesn't have any record yet, it gives me this error:
- Server Error in '/' Application.
-
- There is no row at position 0.
-
- Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
-
- Exception Details: System.IndexOutOfRangeException: There is no row at position 0.
-
- Source Error:
-
-
- Line 102: catch (Exception ex)
- Line 103: {
- Line 104: throw ex;
- Line 105: }
- Line 106: }
I wanted to show me a sale = 0 if the record doesn't exist. Thanks for any help.