Swornim Nepal Swornim Nepal - 16 days ago 4
SQL Question

How can i get the sum of the values between two dates

my query is

select
ir.ProductId,
sum(ir.IssueQuantity) as 'Quantity',
p.ProductName,
ir.IssueDate,
ir.ReturnDate
from Product.IssueReturn ir
join Company.Product p on p.ProductId=ir.ProductId
group by ir.ProductId,p.ProductName,ir.IssueDate,ir.ReturnDate

Answer
SELECT 
    ProductId ,  PrdName , 
    SUM(IssueQuantity) IssueQuantity ,
    MIN(IssueDate) IssueDate,MAX(ReturnDATE) ReturnDATE 
FROM Table1 join Table2 on ProductId = ProductId 
GROUP BY ProductId , PrdName