hello everyone,
i'm using FPD26
and i have a table like this
(table_01)
trans_id code
0001 A
0001 B
0001 A
0002 C
0002 A
0002 B
and i want to have a result like this
(table_02)
trans_id tot_item
0001 2
0002 3
usually i create two query, the first one use to group the code on transaction_id and save it to temporary table, and the resulting table is like this
(tmp_tbl)
trans_id code
0001 A
0001 B
0002 A
0002 B
0002 C
statement: select trans_id,code;
from table_01;
group by trans_id,code;
into cursor temp_tbl
and the second query will use to count this temp table for each transaction_id to get the result as table_02.
statement: select trans_id,count(trans_id);
from temp_tbl;
group by trans_id;
into tbl table_02
Now my question is ...
Do any of you know a query using only single SQL select statement which resulting a table equal to table_02 above?
i'm using FPD26
and i have a table like this
(table_01)
trans_id code
0001 A
0001 B
0001 A
0002 C
0002 A
0002 B
and i want to have a result like this
(table_02)
trans_id tot_item
0001 2
0002 3
usually i create two query, the first one use to group the code on transaction_id and save it to temporary table, and the resulting table is like this
(tmp_tbl)
trans_id code
0001 A
0001 B
0002 A
0002 B
0002 C
statement: select trans_id,code;
from table_01;
group by trans_id,code;
into cursor temp_tbl
and the second query will use to count this temp table for each transaction_id to get the result as table_02.
statement: select trans_id,count(trans_id);
from temp_tbl;
group by trans_id;
into tbl table_02
Now my question is ...
Do any of you know a query using only single SQL select statement which resulting a table equal to table_02 above?