Answer the question
In order to leave comments, you need to log in
How to write an sql-query for grouping by conditions: more than the average value, less than the average value?
Table
grp | val | date
------------------------
t | 1 | 01-01-1990
f | 3 | 02-01-1990
t | 2 | 03-01-1990
f | 2 | 02-01-1990
f | 1 | 02-01-1990
Промежуток | t | f | sum строк
--------------------------------------------------
больше среднего val | 2 | 2,5 | 2
меньше среднего val | 1 | 1 | 1
--------------------------------------------------
итого | 2 | 3 | 5
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question