Page 1 of 1

Why do I need a Group By?

Posted: Wed Mar 23, 2016 8:37 am
by rencya6
Hello,

Can someone take a gander at the following SQL and please let me know why I am getting the error?

dbadmin=> select min(time) from dc_netstats where node_name = 'v_mydb_node0001' and udp_in_errors <> 0 order by time;
ERROR 2640:  Column "dc_netstats.time" must appear in the GROUP BY clause or be used in an aggregate function

Re: Why do I need a Group By?

Posted: Wed Mar 23, 2016 10:27 am
by JimKnicely
Why are you trying to order by time when you are getting a min time on a single node? That's only a single value. Get rid of the ORDER BY...

Code: Select all

select min(time) from dc_netstats where node_name = 'v_mydb_node0001' and udp_in_errors <> 0;