A tough SQL question (I’m using postgres by the way).
I need the first row inserted every day for the past X days. one of my columns is a timestamp, which i hold the time inserted, and another column is the row id.
If it’s not possible to get the first row inserted every day, i at least need a unique one; a single row for every day for the past x days.
Any suggestions?
Thanks
okie
You may want to try something like the following (tested in MySQL, but I guess it should be easy to port to Postgres):
Note that this assumes that your timestamps are unique.
Test Case (in MySQL):
Result: