Subject | Re: [firebird-support] GROUP BY on column containing white space |
---|---|
Author | Ann W. Harrison |
Post date | 2008-01-31T16:06:33Z |
dominic2256 wrote:
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 ' '.
Good luck,
Ann
>Perhaps, but you're also confused about the way SQL treats
> I'm a little confused about how GROUP BY treats white space in Firebird
> 1.5.4.
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 ' '.
>Which is what is required.
> 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.
> Is there any way that I can change this behaviour?You could group by mycol, strlen(mycol).
Good luck,
Ann