select sum() from tb1 into @a ,这种语句为何报错呢?但是加上 where 就不报错。
select sum(f2)
from tb1
where 1=1 -- 为何这里没有这一句,就会报错呢?
into @a;
select @a;
drop table if exists tb1;CREATE TABLE `tb1` (
`f1` int(11) DEFAULT NULL,
`f2` decimal(18,2) DEFAULT NULL
) ;-- go
insert into tb1 values(1,89.67),(2,67.34),(3,88.12);select *
from tb1;
select sum(f2)
from tb1
where 1=1 -- 为何这里没有这一句,就会报错呢?
into @a;
select @a;
select sum(f2)
from tb1
where 1=1 -- 为何这里没有这一句,就会报错呢?
into @a;
select @a;
drop table if exists tb1;CREATE TABLE `tb1` (
`f1` int(11) DEFAULT NULL,
`f2` decimal(18,2) DEFAULT NULL
) ;-- go
insert into tb1 values(1,89.67),(2,67.34),(3,88.12);select *
from tb1;
select sum(f2)
from tb1
where 1=1 -- 为何这里没有这一句,就会报错呢?
into @a;
select @a;
select sum() from tb1 into @a 这种格式
你太有意思了,sum()是简写呀,我偷懒,我以为大家会明白的。
我总不至于连 sum() 必须有参数也不知道呀。你的回复,我刚明白是什么意思