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
|
Список | pgsql-novice |
2009/11/20 Oliveiros C, <oliveiros.cristina@marktest.pt>
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 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 guessyou should drop the "AND stats_exists" part of the query becauseit 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
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 по дате отправления: