Why do I need a Group By?

Moderator: NorbertKrupa

Post Reply
rencya6
Newbie
Newbie
Posts: 1
Joined: Wed Mar 23, 2016 8:29 am

Why do I need a Group By?

Post by rencya6 » Wed Mar 23, 2016 8:37 am

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
cong ty rut ham cau gia re

User avatar
JimKnicely
Site Admin
Site Admin
Posts: 1825
Joined: Sat Jan 21, 2012 4:58 am
Contact:

Re: Why do I need a Group By?

Post by JimKnicely » Wed Mar 23, 2016 10:27 am

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;
Jim Knicely

Image

Note: I work for Vertica. My views, opinions, and thoughts expressed here do not represent those of my employer.

Post Reply

Return to “Vertica SQL”