Subject Re: [firebird-support] SQL Question
Author Arno Brinkman
Hi,

> I need to build a SQL statement, but it seems to be more difficut than
> expected.
>
> ID, Number, Number2
> 1 10 58
> 2 10 58
> 3 11 58
> 4 11 58
> 5 12 59
> 6 12 59
> 7 12 59
>
> I need to know how many times "Number" is present with a different
> "number 1" !
> I.e.
>
> 58 is pressent 2 times (with number 10 and 11)
> 59 is present 1 time (with number 12).
>
> Maybe its just me, but I can't seem to get it to work properbly...

SELECT
Number2,
Count(DISTINCT Number)
FROM
TableX
GROUP BY
Number2

Regards,
Arno Brinkman
ABVisie

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

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

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