Re: Counting booleans for two columns

Поиск
Список
Период
Сортировка
От Thom Brown
Тема Re: Counting booleans for two columns
Дата
Msg-id bddc86150911200711s692ab4fds3c2b9b2ec395717a@mail.gmail.com
обсуждение исходный текст
Ответ на Re: Counting booleans for two columns  ("Oliveiros C," <oliveiros.cristina@marktest.pt>)
Ответы Re: Counting booleans for two columns  (Rikard Bosnjakovic <rikard.bosnjakovic@gmail.com>)
Список pgsql-novice
2009/11/20 Oliveiros C, <oliveiros.cristina@marktest.pt>
SELECT sum(played::integer), sum(stats_exists::integer)
FROM matches
WHERE origin=1 AND stats_exists AND NOT training AND match_date > '2009-08-01';
 
Your approach is elegant, Thom.
 
But if it is to do it that way then I guess
you should drop the "AND stats_exists" part of the query because
it will filter out every line with stats_exists == f, and those (occasionally) played== t won't get summed up  by the SUM() function,
ain't I right ?
 
Best,
Oliveiros
 
Yes, you're right. :) To be honest I didn't really pay much attention to the content of the WHERE clause.  I just tacked it on the end from one of the original selects, but I agree that it should be removed.  So we'd end up with:

SELECT sum(played::integer), sum(stats_exists::integer)
FROM matches
WHERE origin=1 AND NOT training AND match_date > '2009-08-01';

Thom

В списке pgsql-novice по дате отправления:

Предыдущее
От: "Oliveiros C,"
Дата:
Сообщение: Re: Counting booleans for two columns
Следующее
От: Rikard Bosnjakovic
Дата:
Сообщение: Re: Counting booleans for two columns