Subject | How to total such values |
---|---|
Author | ibmcom2011 |
Post date | 2011-12-01T09:23:21Z |
Suppose a table like below:
CREATE TABLE T1(
F1 varchar(20),
V1 integer
);
Now, it has some values in like these:
insert into t1(f1, v1) values(a1, 20);
insert into t1(f1, v1) values(a2, 5);
insert into t1(f1, v1) values(a3, 3);
insert into t1(f1, v1) values(a12, 12);
insert into t1(f1, v1) values(b2, 11);
insert into t1(f1, v1) values(b21, 1);
insert into t1(f1, v1) values(b3, 5);
I hope the result is:
All start as 'a' will be totoled into a new record 'a', and all start as 'b' will be totaled into a new record 'b'.
Certainly, the 'a' and 'b' is only a sample to describe, in fact, I don't know what the client would give me .
CREATE TABLE T1(
F1 varchar(20),
V1 integer
);
Now, it has some values in like these:
insert into t1(f1, v1) values(a1, 20);
insert into t1(f1, v1) values(a2, 5);
insert into t1(f1, v1) values(a3, 3);
insert into t1(f1, v1) values(a12, 12);
insert into t1(f1, v1) values(b2, 11);
insert into t1(f1, v1) values(b21, 1);
insert into t1(f1, v1) values(b3, 5);
I hope the result is:
All start as 'a' will be totoled into a new record 'a', and all start as 'b' will be totaled into a new record 'b'.
Certainly, the 'a' and 'b' is only a sample to describe, in fact, I don't know what the client would give me .