2

I'm working with GridDB's SQL interface in Ubuntu and trying to retrieve the count of sensor data records where the value is greater than 100, grouped by the sensor ID.

However, when executing the query, I receive an error message saying:

Invalid syntax near 'GROUP'

I have double-checked my syntax and it seems correct:

SELECT sensor_id, COUNT(*) AS count 
FROM sensor_data_table 
WHERE value > 100
GROUP BY sensor_id;

What could be causing this error and how can I fix it?

ℛɑƒæĿᴿᴹᴿ
  • 4,983
  • 4
  • 38
  • 58
John Woods
  • 71
  • 2

1 Answers1

0

you'd want something like this because count(*) just returns a single value, also you're using 'count' as a column which is a reserved word

    SELECT sensor_id, COUNT(sensor_id) AS count_sensor
    FROM sensor_data_table
    WHERE value > 100
    GROUP BY sensor_id;
zhiguang
  • 345
  • 1
  • 7