Subject Re: [ib-support] Count and distinct
Author Lucas Franzen
Lester Caine schrieb:
>
> Jason Chapman (JAC2) wrote:
> > Hi Ann,
> > Row 1:
> > x = 'ABC'
> > y = 'DEF'
> > Row 2:
> > x= 'ABCDE'
> > y= 'F'
> >
> > Would break that wouldn't it.
>
> >>select count (distinct (x || y)) from <table>
>
> So -
>
> distinct (x || '!' || y)
>
> where the ! is a 'safe character for your application.

And if there's no "safe character" you still can try using

SELECT COUNT(*) AS CNT, x, y
FROM YOURTABLE
GROUP BY X, Y

walk through the result and sum the CNT fields....
(or let it sum by a stored proc)

Luc.