Subject Re: [firebird-support] COUNT(field > val)
Author Arno Brinkman
Hi,

> SELECT tNo, COUNT(tField > 0) AS POSITIVE,COUNT(tField < 0) AS NEGATIVE,
> COUNT(tField = 0) AS ZEROES (...etc)
> FROM table
> GROUP BY tNo

SELECT tNo,
SUM(CASE WHEN tField > 0 THEN 1 ELSE 0 END) AS POSITIVE,
SUM(CASE WHEN tField < 0 THEN 1 ELSE 0 END) AS NEGATIVE,
SUM(CASE WHEN tField = 0 THEN 1 ELSE 0 END) AS ZEROES (...etc)
FROM
table
GROUP BY
tNo

Regards,
Arno Brinkman
ABVisie

-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
General database developer support:
http://www.databasedevelopmentforum.com

Firebird open source database (based on IB-OE) with many SQL-99 features:
http://www.firebirdsql.org
http://www.firebirdsql.info

Support list for Interbase and Firebird users:
firebird-support@yahoogroups.com

Nederlandse firebird nieuwsgroep:
news://newsgroups.firebirdsql.info