Subject | Re: [firebird-support] group by and where |
---|---|
Author | Thomas Steinmaurer |
Post date | 2012-07-31T05:28:40Z |
> why command "group by" and "where" do not work together?select ... from test1
> Example:
> CREATE TABLE TEST1
>> (
>> COD char(1),
>> SUMA smallint
>> );
>
> INSERT INTO TEST1 (COD, SUMA) VALUES ('A', '3');
>> INSERT INTO TEST1 (COD, SUMA) VALUES ('B', '3');
>> INSERT INTO TEST1 (COD, SUMA) VALUES ('B', '7');
>> INSERT INTO TEST1 (COD, SUMA) VALUES ('A', '4');
>> INSERT INTO TEST1 (COD, SUMA) VALUES ('C', '5');
>> INSERT INTO TEST1 (COD, SUMA) VALUES ('D', '6');
>
>
>
> this work
> SELECT COD, sum(SUMA) as suma
>>FROM (select cod,suma from TEST1 where cod<'C')
>> group by cod ;
>
>
> this do not work
> SELECT COD, sum(SUMA) as suma
>>FROM TEST1
>> group by cod
>> where cod<'C';
where
cod < 'C'
group by
cod
--
With regards,
Thomas Steinmaurer
http://www.upscene.com/