Quantcast
Channel: Forum Getting started with SQL Server
Viewing all articles
Browse latest Browse all 7129

AVG function in a period based on condition

$
0
0

Hi, i have a table like this:

TIMESTAMPFLOW
18/07/2019100
17/07/2019110
16/07/2019120
15/07/2019120
14/07/2019110
13/07/201913
12/07/2019120
11/07/2019120
10/07/2019100
09/07/201912
08/07/201910
07/07/2019100
06/07/2019120
05/07/20193
04/07/20195
03/07/20196
02/07/20194
01/07/20193
30/06/2019300
29/06/2019200
28/06/2019200


I need to do the average of the flow between a the period from TODAY() and another one in the past that follow this rule: FLOW<=20 FOR a period>=5gg. In the table above it would be between 18/07/2019 and  05/07/2019.

How can i write an SQL statement that can do that calculation for me?

Thanks a lot for your help


Viewing all articles
Browse latest Browse all 7129

Trending Articles



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