SQLite Forum

Using windows function
Login

Using windows function

(1) By anonymous on 2020-09-10 15:31:31 [source]

I have a table with 4 columns. Namely accit qtyd qtyr run total I have tried this so far SUM(qtyd-qtdr)FILTER (WHERE t1.accit = t1min.accit)OVER (ORDER BY t1.accit ROWS UNBOUNDED PRECEDING)AS RUNtotal The problem is that it is doing a running total but for all. I need it to do per accit and then the next accit

  1. 5. 2. 3
  2. 2. 1. 4
  3. 5. 1 8 ( here it should be 4 as it is a new accit)

Please help as to where I am going wrong.

(2) By David Raymond (dvdraymond) on 2020-09-10 15:48:25 in reply to 1 [link] [source]

I think you need a "partition by" in there
... over (partition by t1.accit order by...
...but I'm not the most familiar with window functions

(3) By anonymous on 2020-09-10 15:59:28 in reply to 2 [link] [source]

Thanks a lot.It worked. Instead of Order by changed to Partition by.