Skip to content
Advertisement

How to get conditional SUM?

I am trying to get a conditional sum based on another column. For example, suppose I have this dataset:

If there is a type of 1 then I only want that data for that data, else if there is only 0 then I want that data for that date.

So for 12/16/2019 I would want the value 0. For 12/23/2019 – 12/27/2019 I would want the value 7.

Advertisement

Answer

You can use row_number() :

User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement