select t1,t2 into m1,m2
from result1
where t1=(select min(t1) from result1);
from result1
where t1=(select min(t1) from result1);
解决方案 »
- 连接多会有性能问题么?
- linux下安装oracle的问题,大虾请进
- 大家帮我看看这个sql语句怎么写啊?
- 对同一表执行同样的insert操作为何时快时慢?
- C#调用Oracle存储过程出错,当改成对应SQL语句时,不会出错?请看呀,怪不怪?!![分不够,再加。]
- 幫我看一條sql語句,為什麼這麼慢?
- 关于ORACLE的学习
- 开发大型文献管理系统的苦恼
- 百分相赠:ORACLE-12592 求解
- oracle中存储过程一条查询语句怎么加锁可以在commit之后才可以再次执行这条查询语句
- 在sql/plus里面怎么不显示存储过程的结果啊??
- 请问我的oracle enterrise manager sysman的密码忘了,请问还有另的帐号可以登录不?
from result1
where t1=(select min(t1) from result1) and exists (select 1 from result1);
from result1
where t1=(select min(t1) from result1)
group by t1,t2;l_count是个变量
if l_count = 0 then
-- 退出程序
return;
end if;
我照您的方案,但是sql*plus提示出错:
ERROR 位于第 1 行:
ORA-00937: 非单组分组函数
ORA-06512: 在"SYS.PROC_CHECKSECOND", line 62
ORA-06512: 在"SYS.PROC_INITBEGINENDADDRESS", line 62
ORA-06512: 在line 5
我估计是group by 的问题,请帮忙!!
m1 result1.t1%type;
m2 result1.t2%type;
begin
for i in (select count(1) con from result1) loop
if i.con>0 then
select t1,t2 into m1,m2
from result1
where t1=(select min(t1) from result1)
end if;
end loop;
end;
/
你确认你的SQL中,除count(*)外的字段都出现在了group by 子句中吗?如果问题还出现,贴出你的代码瞧瞧。
creat table tb_result1_temp
(check_count number(1),
bus_stop_count number(5),
bus_begin_name varchar2(20),
bus_begin_stop varchar2(20),
bus_change1_stop varchar2(20),
bus_change1_name varchar2(20),
bus_end_stop varchar2(20));表中有值:
insert into tb_result1_temp values(1,5,'86路','农业大学','工大','78路'
,'秋林公司');
insert into tb_result1_temp values(1,8,'21路','农业大学','博物馆','103路'
,'秋林公司');我在运行下列pl/sql块时遇到问题:
declare
i_check_count number(1) := 0;
i_busstop_count number(5) :=0;
i_initmid2_name varchar2(20);
i_initmid2_stop varchar2(20);
i_change1_stop varchar2(20);
i_change1_name varchar2(20);
i_end_stop varchar2(20);
v_result1_rowcount number(5);
begin
select
check_count,
bus_stop_count,
bus_begin_name,
bus_begin_stop,
bus_change1_stop,
bus_change1_name,
bus_end_stop,
count(*)
into
i_check_count,
i_busstop_count,
i_initmid2_name,
i_initmid2_stop,
i_change1_stop,
i_change1_name,
i_end_stop,
v_result1_rowcount
from tb_result1_temp
where bus_stop_count=(select min(bus_stop_count) from tb_reslut1_temp)
order by bus_stop_count;
end;
ora-00917:非单组分组函数
而把order改为group后出错:
ora-00979:不是group by表达式
而在where后什么也不加后出错:
ora-00917:非单组分组函数
请帮忙改正!!!
后加
group by bus_stop_count, bus_begin_name, bus_begin_stop, bus_change1_stop, bus_change1_name, bus_end_stop没想到你有这么多字段,你也可以用exception
declare
i_check_count number(1) := 0;
i_busstop_count number(5) :=0;
i_initmid2_name varchar2(20);
i_initmid2_stop varchar2(20);
i_change1_stop varchar2(20);
i_change1_name varchar2(20);
i_end_stop varchar2(20);
v_result1_rowcount number(5);
begin
select
check_count,
bus_stop_count,
bus_begin_name,
bus_begin_stop,
bus_change1_stop,
bus_change1_name,
bus_end_stop
into
i_check_count,
i_busstop_count,
i_initmid2_name,
i_initmid2_stop,
i_change1_stop,
i_change1_name,
i_end_stop
from tb_result1_temp
where bus_stop_count=(select min(bus_stop_count) from tb_reslut1_temp)
order by bus_stop_count;exception
when no_data_found then --没有记录
..
end;
/还有select into应该只可以选出一条记录,order by是没有意义的。
group by 后应加上所以得select里的列名。
谢谢各位的帮忙!!!