Re: Datetime in group and order by clauses.
Posted in 1994
nick@anix.demon.co.uk (Nick Valentine) writes: >I have a table with a datetime column (Year to Minute) and I want to >create sql scripts that will give me statistics group on monthly, daily >and hourly intervals. Is there any way that I can group and order by >the components within a datetime file. The manual doesn't mention anything >about grouping and ordering on datetime columns, at least not in the sections >I'm looking at. This is untried, but should work: ORDER BY EXTEND(column, HOUR TO MINUTE) If that doesn't work you make have to: SELECT ... EXTEND(column, range) alias ... ORDER BY alias EXTEND can either make a DATETIME/INTERVAL more or less precise; if you EXTEND a YEAR TO HOUR into a YEAR TO SECOND, for instance, 00:00 is considered the extension. ======================================================================= Dennis J. Pimple dennisp@informix.com Opinions expressed are Senior Consultant -------------------- soley my own, & do not Informix Software Inc Voice: 303-850-0210 necessarily reflect Denver Colorado USA Fax: 303-779-4025 those of my employer.