为什么我的SQL2000说isempty()是一个无法识别的函数呢?
另外我想在SELECT里嵌套IF语句,如何写这个语句呢?
table A (a,b,c)
table B (e,f,g)
table C (h,i,j)
我用select into 语句去读 A.a,如果a为空或者为0,,我就把这列付值为B.e,否则我就赋值C.h
...全文
398打赏收藏
高手请进,急急。。。。。多谢多谢。。。
为什么我的SQL2000说isempty()是一个无法识别的函数呢? 另外我想在SELECT里嵌套IF语句,如何写这个语句呢? table A (a,b,c) table B (e,f,g) table C (h,i,j) 我用select into 语句去读 A.a,如果a为空或者为0,,我就把这列付值为B.e,否则我就赋值C.h
今天有空上来一看
select ( case when isnull(A.a,0) <> 0 then A.a
when isnull(A.a,0) = 0 and isnull(B.e,0) <> 0 then B.e
else C.h end) as xxx
from A,B,C
where your condition
发现,我少写了一个end,呵呵,对不住啦.
table: a (a1,a2,a3)
table: b (b1,b2,b3)
talbe: c (c1,c2,c3)
在a里有很多数据,我全部需要,但是对我有用的只有几列,其中a3是一个判断条件,如果a3是一个空值,我就把这列用b.b2赋值,如果他不是空的,我就用c.c2赋值
select a.a1,a.a2,(case when isnull(a.a3,0)<>0 then c.c2
when isnull(a.a3,0)==0 then b.b2) as xxx
into abc
form a,b,c
然后提示我说:')' 附近有语法错误。
select ( case when isnull(A.a,0) <> 0 then A.a
when isnull(A.a,0) = 0 and isnull(B.e,0) <> 0 then B.e
else C.h ) as xxx
from A,B,C
where your condition