Subject Re: [firebird-support] get number of combinations of to keys
Author Svein Erling Tysvær
Well, you need to know more about PRO and FA than we do, but if they are character fields and neither of them can include _, then maybe:

select count( distinct coalesce( PRO, '' ) || '_' || coalesce( FA, '' ) ) ProFaCount
from Tab
where Key = :Key

would work. The COALESCE is there in case the fields could be NULL. If PRO and FA are non-null numbers and FA always is between 0 and 99, then the query would be

select count( distinct ( 100 * PRO ) + FA ) ProFaCount
from Tab
where Key = :Key 

HTH,
Set

Den man. 16. jul. 2018 kl. 08:58 skrev Josef.Gschwendtner@... [firebird-support] <firebird-support@yahoogroups.com>:


Hi,


Is there a way to get this ProFaCount in one statement (without for select)


ProFaCount = 0;
for
  select distinct PRO, FA
    from Tab
   where Key = :Key
    into :PRO, :FA
do
 
ProFaCount =
ProFaCount + 1;

Thank you for your help.


Regards,

Josef