houssem ayari

houssem ayari

  • 2.1k
  • 20
  • 524

The subquery return multiple values.

Apr 26 2021 8:12 AM
Hello I am working on SQL query that updates my container automatically but I got this error that makes my SQL query don't work :
 
' The subquery return multiple values. This is not allowed when the subquery follows =,! =, <, <=,>,> = Or when it is used as an expression. '
 
This is my full query and the part that makes the problem is under : 
  1. INSERT INTO [CRM_GAT].[dbo].[Table_Audit_Sinistres]([Libelle_Etape],[time],[Count_Input],[NumSinistre],[Count_Output])  
  2. VALUES ('FIN_TR_Sinistre',GEtDATE()  
  3. ,(SELECT COUNT(*)FROM [CRM_GAT].[dbo].[Sinistre] WHERE ([CodeValidation] is null or [CodeValidation]=0) and [DateOperation] between DATEADD(day,-10, GETDATE()) and GETDATE()),  
  4. (SELECT [NumSinistre]FROM [CRM_GAT].[dbo].[Sinistre] where [NumContrat] in(select [NumContrat] from [CRM_GAT].[dbo].[Contrats] where [CodeProduit]!=7940 and [DateOperation] between DATEADD(day,-10, GETDATE()) and GETDATE())  
  5. and [DateOperation] between DATEADD(day,-10, GETDATE()) and GETDATE() and ([CodeValidation] is null or [CodeValidation]=0 ))  
  6. ,(SELECT COUNT(*) FROM [CRMGAT].[dbo].[Sinistre] WHERE [CtrCodeSource]=1 and [DateOperation] between DATEADD(day,-10, GETDATE()) and GETDATE()))  
  7.    
  8. SELECT [NumSinistre]FROM [CRM_GAT].[dbo].[Sinistre] where [NumContrat] in(select [NumContrat] from [CRM_GAT].[dbo].[Contrats] where [CodeProduit]!=7940 and [DateOperation] between DATEADD(day,-10, GETDATE()) and GETDATE())  
  9. and [DateOperation] between DATEADD(day,-10, GETDATE()) and GETDATE() and ([CodeValidation] is null or [CodeValidation]=0 )   
I need to get all the values and insert them in my table.
 
Please can someone help me

Answers (1)