Re: DONT_CARE Aggregate
От | Chris Curvey |
---|---|
Тема | Re: DONT_CARE Aggregate |
Дата | |
Msg-id | CADfwSsBzN3LcJHi_WjiuHTfQQ56GAuO-6rM5M2-bX38TXwz6aQ@mail.gmail.com обсуждение исходный текст |
Ответ на | Re: DONT_CARE Aggregate (Robert James <srobertjames@gmail.com>) |
Список | pgsql-general |
On Thu, Dec 20, 2012 at 12:00 PM, Robert James <srobertjames@gmail.com> wrote:
-- I see. What if I need to do this along with an Aggregate Query. Eg
something like:
SELECT x,y,z, MAX(a), MAX(b), DONT_CARE_AS_LONG_AS_NOT_NULL(c),
DONT_CAR_AS_LONG_AS_P_IS_TRUE(d,p)
...
GROUP BY x,y,z
ah, I get what you're trying to do. If you truly don't care about the value of C, then just use MIN() or MAX().
for the conditional part, use a CASE statement, along with MAX or MIN, like this:
SELECT MIN(CASE WHEN P=TRUE THEN D ELSE NULL END)
Because MIN() and MAX() ignore NULL values. (Except for the special case where all the values are null.)
e-Mail is the equivalent of a postcard written in pencil. This message may not have been sent by me, or intended for you. It may have been read or even modified while in transit. e-Mail disclaimers have the same force in law as a note passed in study hall. If your corporate attorney says that you need an disclaimer in your signature, you need a new corporate attorney.
В списке pgsql-general по дате отправления: