I have a table in Postgres called calendar and I am trying to query the first date value stored where year=2013.
I have written the following query which works, however I am wondering if I can query the first date instead of just getting all data and limiting just to one?
SELECT date FROM calendar WHERE year=2013 ORDER BY date ASC LIMIT 1
datecolumn (which btw. is a horrible name for a column), then Postgres will not "get all the data". You could do something likewhere date = (select max(date) from calendar)but that won't be more efficient.where year=2013so i presume you are not using a timestamp or date column?CREATE TABLEstatements) and preferably some sample data. Your PostgreSQL version should also be in every single question.