On 2018/03/21 5:30 PM, Ron Watkins wrote:
I have a table which contains a datetime column:



table|foo|foo|2|CREATE TABLE foo (

         dttm    datetime        not null

         i int             not null

)



I want to select out the max(i) value for each day where there are multiple
records per day.



select date(dttm) dt,max(i) from foo group by dt order by 1;



However, it’s returning only 1 row, with no date column shown. How can I
get an actual “date” listed in the first column, and also get 1 row per
“date” value.

I fear I might be missing something obvious, but wouldn't this just do the job?:
SELECT date(dttm) AS dt, max(i)
  FROM foo
 GROUP BY date(dttm)

If you still get only 1 row, it means there is only 1 date value in all the rows in your table.


_______________________________________________
sqlite-users mailing list
sqlite-users@mailinglists.sqlite.org
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to