Click here to Skip to main content
15,896,207 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hi friends

my query is like,
SQL
select  ER.BUSINESSNAME as ClientName,E.EMPLOYEE_FIRSTNAME+' '+E.EMPLOYEE_LASTNAME as EmployeeName,

        ISNULL((select TotalAmount from dbo.tblClientBenfitesForEmployee where  EmployerID=7 and SupportedID=1 ),0) as Advance,
         ISNULL((select TotalAmount from dbo.tblClientBenfitesForEmployee where   EmployerID=7 and SupportedID=2),0) as Child,
          ISNULL((select TotalAmount from dbo.tblClientBenfitesForEmployee where  EmployerID=7 and SupportedID=3) ,0)as Health
             from dbo.tblAssignEmployeesToClients  AEC
             inner join dbo.EMPLOYEE_DETAILS E on AEC.EmployeeID=E.EMPLOYEE_ID
             inner join dbo.EMPLOYER_REGISTRATION ER on AEC.EmployerID=ER.EMPLOYER_ID
             inner join dbo.tblClientBenfitesForEmployee CBF on AEC.EmployerID=CBF.EmployerID
             inner join dbo.tblClientBenfitesList CB on CBF.SupportedID=CB.SupportID

             where AEC.EmployerID=7


i got the error
XML
Msg 512, Level 16, State 1, Line 1
Subquery returned more than 1 value. This is not permitted when the subquery follows =, !=, <, <= , >, >= or when the subquery is used as an expression.


how to solve my error.. please help me and give me any ideas.
Posted

Apply limit 0,1 in subquery may resolve the issue
 
Share this answer
 
you are getting more than 1 rows for TotalAmount in tblClientBenfitesForEmployee
SQL
select  ER.BUSINESSNAME as ClientName,E.EMPLOYEE_FIRSTNAME+' '+E.EMPLOYEE_LASTNAME as EmployeeName,

        ISNULL((select Top 1 TotalAmount from dbo.tblClientBenfitesForEmployee where  EmployerID=7 and SupportedID=1 ),0) as Advance,
         ISNULL((select Top 1 TotalAmount from dbo.tblClientBenfitesForEmployee where   EmployerID=7 and SupportedID=2),0) as Child,
          ISNULL((select Top 1 TotalAmount from dbo.tblClientBenfitesForEmployee where  EmployerID=7 and SupportedID=3) ,0)as Health
             from dbo.tblAssignEmployeesToClients  AEC
             inner join dbo.EMPLOYEE_DETAILS E on AEC.EmployeeID=E.EMPLOYEE_ID
             inner join dbo.EMPLOYER_REGISTRATION ER on AEC.EmployerID=ER.EMPLOYER_ID
             inner join dbo.tblClientBenfitesForEmployee CBF on AEC.EmployerID=CBF.EmployerID
             inner join dbo.tblClientBenfitesList CB on CBF.SupportedID=CB.SupportID

             where AEC.EmployerID=7

Happy Coding!
:)
 
Share this answer
 
Comments
Santhosh23 28-Feb-13 8:31am    
hi Aarti., Than q for your replay. but in my table Employer 7 having 14 records. how to display all records please help me Aarti..

than q and Regards
Aarti Meswania 28-Feb-13 8:45am    
Is this related to above query posted in Question?
I haven't know table structures and actual requirement I will need brief for this
you should check joins
Santhosh23 28-Feb-13 9:24am    
your above codeing working fine..
Aarti Meswania 28-Feb-13 23:16pm    
thank u! :)
Glad to help u! :)

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