select substr(name,1,1),count(1) from a group by substr(name,1,1);
解决方案 »
- 请问各位高手
- 急!!!!mview 取另一个数据库的数据
- oracle使用序列的问题
- 大家帮忙分析这个SQL,高分哦
- oracle手中手工创建数据库时指定SYS密码了,为什么指定的密码不可用?还要创建密码文件?创建密码文件时也要指定密码,那创建数据库时指定的密码不就没有用处
- 请问这个触发器怎么写
- Oracle 中不可以使用 top 字句吗?
- 用oracle发邮件标题乱码的问题
- 为什么安装了java 2 SDK1.3.1却总是抛出异常:找不到javax\sql\DataSource.class
- 字段空值问题(万急!!!)
- 搞不定了
- ADO与Oracle配合使用,在Oracle SQL Plus出错的语句,在ADO中不出错,奇怪!!!!
select substr(name,1,1),count(1) from a group by substr(name,1,1);好像不可以吧
我的意思比如说a表name字段中 有“王××”的记录20条,那么统计出来就是20,但是要把比表中所有的姓都要有个统计
复姓怎么办?
来做判断后 GROUP BY
a(name,a_id)姓名,姓编码
b(b_id,name)编码,姓create trigger a_tri
before insert on a
for each row
begin
for i in 1..10 loop
for c in (select b_id,name from b) loop
if substr(:new.name,i,1)=c.name then
:new.a_id:=c.b_id;
goto next_label;
end if;
end loop;
end loop;
<<next_label>>
null;
end;
/select count(1),(select name from b where b_id=a_id) from a group by a_id;
来做判断后 GROUP BY
<<<<<<<<<<<<<<<<<<<<<<<
但是姓可能会有很多种情况(这边用姓名只是举个例子好说点),用group by可能就麻烦点
<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
就是在一个表一样不能解决这个问题啊
a(name,a_id)姓名,姓编码
b(b_id,name)编码,姓create trigger a_tri
before insert on a
for each row
begin
for i in 1..10 loop
for c in (select b_id,name from b) loop
if substr(:new.name,i,1)=c.name then
:new.a_id:=c.b_id;
goto next_label;
end if;
end loop;
end loop;
<<next_label>>
null;
end;
/select count(1),(select name from b where b_id=a_id) from a group by a_id;
<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
好像一样不可以解决复姓的问题