sairam62.cse
select a.product,sum(b.price) as totprice from table a,table b where a.sno<=b.sno group by a.product
having sum(b.price)<=x
Change to:
SELECT a.ProductID, a.Price FROM @Products a, @Products b WHERE b.ProductID <= a.ProductID GROUP BY a.ProductID, a.Price Having SUM(b.Price)<1000 ORDER BY ProductID, Price