Re: [SQL] sum(bool)?

2001-02-26 Thread Oliver Elphick
Olaf Marc Zanger wrote: >hi there, > >i want to add up the "true" values of a comparison like > >sum(a>b) > >it just doesn't work like this > >any workaround? select count(*) where a > b; -- Oliver Elphick[EMAIL PROTECTED] Isle of Wight

Re: Fwd: Re: [SQL] sum(bool)?

2001-02-25 Thread D'Arcy J.M. Cain
Thus spake J.Fernando Moyano > El Viernes 23 Febrero 2001 16:22, escribiste: > > i want to add up the "true" values of a comparison like > > > > sum(a>b) > > > > it just doesn't work like this > > > > any workaround? > > I did exactly the same thing two months ago > > I created this tiny fu

Fwd: Re: [SQL] sum(bool)?

2001-02-25 Thread J.Fernando Moyano
El Viernes 23 Febrero 2001 16:22, escribiste: > hi there, > > i want to add up the "true" values of a comparison like > > sum(a>b) > > it just doesn't work like this > > any workaround? > > it is postgresql 7.0 under linux > > thanks > > olaf I did exactly the same thing two months ago I c

[SQL] sum(bool)?

2001-02-24 Thread Olaf Marc Zanger
hi there, i want to add up the "true" values of a comparison like sum(a>b) it just doesn't work like this any workaround? it is postgresql 7.0 under linux thanks olaf -- soli-con Engineering Zanger, Dipl.-Ing. (FH) Olaf Marc Zanger Lorrainestrasse 23, 3013 Bern / Switzerland fon:+41-31-

Re: [SQL] sum(bool)?

2001-02-23 Thread Andrew Perrin
Or how about just: SELECT count(*) FROM tablename WHERE a > b; -- Andrew J Perrin - Ph.D. Candidate, UC Berkeley, Dept. of Sociology Chapel Hill, North Carolina, USA - http://demog.berkeley.edu/~aperrin [EMAIL PROTECTE

Re: [SQL] sum(bool)?

2001-02-23 Thread Olaf Zanger
hi there, s cool, this works streight away and took 5 min. waiting for a answer :-) thanks very much to you tod personal and the mailing list for existence. Olaf Tod McQuillin schrieb: > > On Fri, 23 Feb 2001, Olaf Zanger wrote: > > > i'd like to add up the "true" values of a comparison

Re: [SQL] sum(bool)?

2001-02-23 Thread Peter Eisentraut
Olaf Zanger writes: > i'd like to add up the "true" values of a comparison like > > sum(a>b) sum(case when a>b then 1 else 0 end) of maybe even just select count(*) from table where a>b; -- Peter Eisentraut [EMAIL PROTECTED] http://yi.org/peter-e/

Re: [SQL] sum(bool)?

2001-02-23 Thread Tod McQuillin
On Fri, 23 Feb 2001, Olaf Zanger wrote: > i'd like to add up the "true" values of a comparison like > > sum(a>b) > > it just doesn't work like this Try sum(case when a>b then 1 else 0 end) -- Tod McQuillin

[SQL] sum(bool)?

2001-02-23 Thread Daniel Wickstrom
> "Olaf" == Olaf Zanger <[EMAIL PROTECTED]> writes: Olaf> hi there i'd like to add up the "true" values of a Olaf> comparison like Olaf> sum(a>b) Olaf> it just doesn't work like this Olaf> any workaround Try using a case statement: select sum(case when a > b then 1 e

[SQL] sum(bool)?

2001-02-23 Thread Olaf Zanger
hi there i'd like to add up the "true" values of a comparison like sum(a>b) it just doesn't work like this any workaround postgres 7.0 on linux thanks olaf -- soli-con Engineering Zanger Dipl.-Ing. (FH) Olaf Marc Zanger Lorrainestrasse 23 3013 Bern / Switzerland Fon: +41-31-332 9782 Mob: +