Hi
Bandi
How to fixed this?
Create Table Head1
(
id int primary key identity(1,1),
BillNo int
)
--Drop table det1
Create Table det1
(
id int primary key identity(1,1),
ProductName varchar(40),
BillNo int,
Qty int,
Rate decimal(18,2),
Amount decimal(18,2)
)
--Insert into Head1 values(1001)
--Insert into Head1 values(1002)
--Insert into Head1 values(1003)
--Insert into Head1 values(1004)
--Insert into Head1 values(1005)
--Insert into det1 values('Mouse1',1001,2,100,200)
--Insert into det1 values('Mouse2',1001,3,100,300)
--Insert into det1 values('Mouse3',1002,4,100,400)
--Insert into det1 values('Mouse4',1005,2,100,200)
--Insert into det1 values('Mouse5',1003,8,100,800)
--Insert into det1 values('Mouse6',1003,5,100,500)
Select * from Head1
Select * from det1
-- My Query This
Select e.Id,e.BillNo,d.ProductName,
(SELECT sum(d.Amount)as amount FROM det1 f where f.BillNo=e.BillNo)
from det1 d inner join Head1 e on
d.BillNo=e.BillNo group by e.Id,e.BillNo,d.ProductName
-- Error
--Subquery returned more than 1 value. This is not permitted when the subquery follows =, !=, <, <= , >, >= or when the subquery is used as an expression.
-- My output this
--Sno BillNo Productname Amount
1 1001 Mouse1 500.00
2 1002 Mouse3 400.00
3 1003 Mouse5 13000.00
Mark as Answer if its helpful to you
Kumaraspcode2009@gmail.com