Quantcast
Channel: Transact-SQL forum
Viewing all articles
Browse latest Browse all 23857

Help Please -Running Totals Trying to use Partition By

$
0
0

I have tried this but get a syntax error near 'ROWS' -for the life of me I cannot figure it out.  Basically what I need is a running total of the rtv_qty by model_id and cust_id in date order.  

Any help is appreciated

SELECT   model_id, 
         cust_id, 
         date_id, 
         rtv_qty,
         sum(rtv_qty) OVER 
                      (PARTITION BY model_id + cust_id 
                       ORDER BY date_id 
                       ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW) 
                       AS cum_rtv_qty
FROM     dbo.cust_return_to_vendor  


Viewing all articles
Browse latest Browse all 23857

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>