Search Postgresql Archives

Re: Select/Group by/Order by question

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



> You are grouping/ordering by the textual result of to_char(),
> in which PM naturally follows AM.  I think the behavior you
> want would come from grouping/ordering by the underlying
> timestamp column "mtrantime".

Well, I need it grouped by hour, but that led me to the solution:

select to_char(date_trunc('hour',mtrantime),'mm-dd hh AM') as
datetime, count(*) as tot, from memtran 
group by mtranoper, date_trunc('hour',mtrantime)
order by mtranoper, date_trunc('hour',mtrantime)

I knew there had to be a straight-forward solution.  Thanks Tom.
--
Mike Nolan

---------------------------(end of broadcast)---------------------------
TIP 3: if posting/reading through Usenet, please send an appropriate
      subscribe-nomail command to majordomo@postgresql.org so that your
      message can get through to the mailing list cleanly

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux