Apurva Singh

Apurva Singh

  • NA
  • 268
  • 52.8k

sub query with group by

Jun 25 2019 12:58 AM
I have a stored procedure for returning data in one row with sub query,but i am getting a error that 
 
Only one expression can be specified in the select list when the subquery is not introduced with EXISTS.
 
 
I am providing you my stored procedure please check and give me solution.
 
 
 
CREATE proc [dbo].[GetChartDetails]
@type varchar(50)
as
begin
select
(select SUM(PaidAmt)as LifeInsurance, DATENAME(MONTH, CreateDate) Month_name from CutomerPaymentDetail where categorytype='LIFE INSURANCE' and type=@type group by DATENAME(MONTH, CreateDate)) ,
(select SUM(PaidAmt)as GIC ,DATENAME(MONTH, CreateDate) Month_name from CutomerPaymentDetail where categorytype='GIC' and type=@type group by DATENAME(MONTH, CreateDate)) ,
(select SUM(PaidAmt)as MutualFund ,DATENAME(MONTH, CreateDate) Month_name from CutomerPaymentDetail where categorytype='MUTUAL FUND' and type=@type group by DATENAME(MONTH, CreateDate))
end
 
 

Answers (4)