Subject Re: [firebird-support] GROUP BY on column containing white space
Author Ann W. Harrison
dominic2256 wrote:
>
> I'm a little confused about how GROUP BY treats white space in Firebird
> 1.5.4.

Perhaps, but you're also confused about the way SQL treats
trailing blanks. When comparing two strings of different
lengths, the SQL standards specifies that an implementation
shall compare them as if the shorter string were extended
to the length of the longer string and blank fill the
extended space. Thus ' ' compares equal to ' '.

>
> The issue is illustrated when the following query is run:
>
> SELECT
> mycol,
> strlen(mycol) as mycol_len,
> count(*)
> FROM test_whitespace_groupby
> GROUP BY mycol
>
> I was expecting the white space to be treated as 4 different values but
> it seems that all the white space values get lumped into a single value
> with a length of 3 characters.

Which is what is required.

> Is there any way that I can change this behaviour?

You could group by mycol, strlen(mycol).

Good luck,


Ann