Re: Group By, Aggregate Functions and NULL
От | Andrew Hammond |
---|---|
Тема | Re: Group By, Aggregate Functions and NULL |
Дата | |
Msg-id | 1154023923.713545.144900@i42g2000cwa.googlegroups.com обсуждение исходный текст |
Ответ на | Group By, Aggregate Functions and NULL (Brendon Gleeson <brendon@gleesonprop.co.za>) |
Список | pgsql-novice |
Brendon Gleeson wrote: > I need to Group By a date column that may contain a NULL value. Min() only > gives me the lowest date and not NULL if it exists. How do I get a Group By > clause to give me NULL if it exists? There are a couple of ways to approach this, but it depends on what exactly you're trying to accomplish, which is not completely clear from your question. I'll take a shot in the dark and guess that you want all the NULLs to group together and sort out lower than your other values. If that's what you want then perhaps a query such as the following would work for you: SELECT COALESCE(ts, '-infinity'::timestamp) FROM mytable GROUP BY 1 ORDER BY 1; For further details please see the following: http://www.postgresql.org/docs/current/static/functions-conditional.html http://www.postgresql.org/docs/current/static/datatype-datetime.html Drew
В списке pgsql-novice по дате отправления: