;WITH CTE AS(
SELECT
(Select TOP(1) [Date] from Calender where [Date]=ord.[Posting Date] )AS [Date],
[Posting Date],
sum(ord.[Quantity])OVER(PARTITION BY prod.No_,[Posting Date] ORDER BY [Posting Date]) AS [Quantity]
FROM [Snowman Logistics Limited$Item Ledger Entry] ord
INNER JOIN [Snowman Logistics Limited$Item] prod
ON ord.[Item No_]=prod.No_ where prod.[No_]='H1023038'and [Posting Date] < @DateTo )
SELECT * FROM CTE
where [Posting Date] between @DateFrom and @DateTo
order By [Posting Date]