Subject | group by and where |
---|---|
Author | Virna Constantin |
Post date | 2012-07-31T05:25:47Z |
Hey,
why command "group by" and "where" do not work together?
Example:
CREATE TABLE TEST1
SELECT COD, sum(SUMA) as suma
SELECT COD, sum(SUMA) as suma
[Non-text portions of this message have been removed]
why command "group by" and "where" do not work together?
Example:
CREATE TABLE TEST1
>(INSERT INTO TEST1 (COD, SUMA) VALUES ('A', '3');
> COD char(1),
> SUMA smallint
>);
>INSERT INTO TEST1 (COD, SUMA) VALUES ('B', '3');this work
>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');
SELECT COD, sum(SUMA) as suma
>FROM (select cod,suma from TEST1 where cod<'C')this do not work
>group by cod ;
SELECT COD, sum(SUMA) as suma
>FROM TEST1Thanks in advance.
>group by cod
>where cod<'C';
[Non-text portions of this message have been removed]