I have this:
SELECT name, value,
MIN(value) as find_min
FROM history
WHERE date_num >= 1609459200
AND date_num <= 1640995200
AND name IN('A')
GROUP BY name
Trying to get the minimum value between dates for each subject separately :
name value
A. 3
B 4
C 9
A 0
C 2
I keep getting this popular error:
column "history.value" must appear in the GROUP BY clause or be used in an aggregate function
I read this must appear in the GROUP BY clause or be used in an aggregate function
and I still do not understand:
- Why I have to include in GROUP BY everything? what is the logic?
- Why is this not working?
- is
Min() over (partition by name)
better, and if so, how can I get only a single result pername
?
EDIT:
If I try:GROUP BY name, find_min
it will fail as well, even though in this case he can produce a unique result (the all the same)