分组的问题,您请看看。。。
love7 2003-10-10 02:30:14 说明一下,该问题先在ORACLE版块中问了,但那边人气没这边旺。
decode是一个选择函数。
select
decode(substr(t0.cag_no,1,1),1,'ab',2,'cd',3,'ef') 分类,
cag_na 名称,
sum(...) 数量
from tabele t0
group by substr(t0.cag_no,1,1),cag_na
显示如下 注:cast_no的值为1023,1024,2034,3023等等。
分类 名称 数量
ab test1 3
ab test2 1
ab test3 5
cd test7 10
cd test9 3
ef test4 2
ef test8 8
现在希望显示如下的结果。解决了立即给分。谢谢。
分类 名称 数量
ab test1 3
test2 1
test3 5
cd test7 10
test9 3
ef test4 2
test8 8