Case in PostgresQL query

I am trying to use Grafana to retrieve data from a Postgresql database. While testing, I got to trying the following Postgresql request:

SELECT entity_id, timestamp, AmbHum from trend.airbox;

If I remove AmbHum it works, and the AmbHum column exists in the database table, but in this form it gives the following error message:

pq: column t.ambhum does not exist

Apparently Grafana is changing the request to lowercase. Is there a way to resolve this dilemma?

That’s a postgres feature. From the postgres docs:

unquoted identifiers are case insensitive

See:

1 Like

Actually nonquoted identifiers are folded to lowercase in postgres.

This query should work:

SELECT entity_id, timestamp, "AmbHum" from trend.airbox;
1 Like

Haha - that’s what I was trying to say but your explanation is clearer.

Thanks both! Great to get such a quick & good answer :slight_smile: