SELECT t1.*,case when is null(a3.F_AAA_REMARKS,'')<>'' then a3.F_AAA_REMARKSwhen is null(a4.F_AAA_REMARKS,'')<>'' then a4.F_AAA_REMARKSwhen is null(a5.FCOMMENT,'')<>'' then a5.FCOMMENTwhen is null(a6.FNote,'')<>'' then a6.FNote else '' end FRemarksintoTMPC828244C9D0F11E7B195005056EFROMTMPC828244D9D0F11E7B195005056E /*后台应收账款明细表的临时表*/ t1left join t_AR_receivable a3 on t1.FFORMID='AP_receivable' and t1.fid=a3.fidleft join T_AR_OttherRecAble a4 on t1.FFORMID='T_AR_OttherRecAble' and t1.fid=a4.fidleft join T_AR_RECEIVEBILLENTRY a5 on a5.fformid='T_AR_RECEIVEBILLENTRY' and t1.fid=a5.fid and a5.FSEQ=1left join T_AR_REFUNDBILLENTRY a6 on t1.fformid='T_AR_REFUNDBILLENTRY' and t1.fid=a6.fid and a6.FSEQ=1
各位大神,请问这个是哪里错了,需要怎么改,谢谢
22 个解决方案
#1
第一眼看去,第三行 when 前面要有空格
<>'' then a4.F_AAA_REMARKSwhen is null(a5.FCOMMENT,'')<>'' then a5.FCOMMENT when is null(a6.FNote,'')
#2
看错了,sorry
#3
is null改成isnull
#4
楼主是不是这个意思
SELECT t1.*,case when isnull(a3.F_AAA_REMARKS,'')<>'' then a3.F_AAA_REMARKS
when a3.F_AAA_REMARKS isnull(a4.F_AAA_REMARKS,'')<>'' then a4.F_AAA_REMARKS
when a4.F_AAA_REMARKS isnull(a5.FCOMMENT,'')<>'' then a5.FCOMMENT
when a5.FCOMMENT isnull(a6.FNote,'')<>'' then a6.FNote
else '' end from
t1 left join t_AR_receivable a3 on t1.FFORMID='AP_receivable' and t1.fid=a3.fid
left join T_AR_OttherRecAble a4 on t1.FFORMID='T_AR_OttherRecAble' and t1.fid=a4.fid
left join T_AR_RECEIVEBILLENTRY a5 on a5.fformid='T_AR_RECEIVEBILLENTRY' and t1.fid=a5.fid and a5.FSEQ=1
left join T_AR_REFUNDBILLENTRY a6 on t1.fformid='T_AR_REFUNDBILLENTRY' and t1.fid=a6.fid and a6.FSEQ=1
#5
原来是isnull的,报错了,我才改为is null
#6
#7
已经提示你啦
is null(a6.FNote,'') 你应该是想要 isnull(a6.FNote,'') 多了空格
SELECT t1.*,case when isnull(a3.F_AAA_REMARKS,'')<>'' then a3.F_AAA_REMARKS,when isnull(a4.F_AAA_REMARKS,'')<>'' then a4.F_AAA_REMARKS,when isnull(a5.FCOMMENT,'')<>'' then a5.FCOMMENT,when isnull(a6.FNote,'')<>'' then a6.FNote else '' end FRemarksintoTMP3707BF8A9D2011E7B195005056EFROMTMP3707BF8B9D2011E7B195005056E /*后台应收账款明细表的临时表*/ t1left join t_AR_receivable a3 on t1.FFORMID='AP_receivable' and t1.fid=a3.fidleft join T_AR_OttherRecAble a4 on t1.FFORMID='T_AR_OttherRecAble' and t1.fid=a4.fidleft join T_AR_RECEIVEBILLENTRY a5 on a5.fformid='T_AR_RECEIVEBILLENTRY' and t1.fid=a5.fid and a5.FSEQ=1left join T_AR_REFUNDBILLENTRY a6 on t1.fformid='T_AR_REFUNDBILLENTRY' and t1.fid=a6.fid and a6.FSEQ=1
#10
sql server 2012的数据库
#11
#12
你这表名好长啊,from呢
from FRemarksintoTMP3707BF8A9D2011E7B195005056EFROMTMP3707BF8B9D2011E7B195005056E
#13
看到了,你没加空格,都一起了
"into {0}"
+ "FROM {1}
#14
看到了,你没加空格,都一起了
"into {0}"
+ "FROM {1}
哪里错了呀,、求指点?
#15
+ " FROM {1} /*后台应收账款明细表的临时表*/ t1"
+ " left join t_AR_receivable a3 on t1.FFORMID='AP_receivable' and t1.fid=a3.fid"
+ " left join T_AR_OttherRecAble a4 on t1.FFORMID='T_AR_OttherRecAble' and t1.fid=a4.fid"
+ " left join T_AR_RECEIVEBILLENTRY a5 on a5.fformid='T_AR_RECEIVEBILLENTRY' and t1.fid=a5.fid and a5.FSEQ=1"
+ " left join T_AR_REFUNDBILLENTRY a6 on t1.fformid='T_AR_REFUNDBILLENTRY' and t1.fid=a6.fid and a6.FSEQ=1";
空格!单词间要有空格
#16
都有空格的,现在提示isnull后有错误
#17
都有空格的,现在提示isnull后有错误
when then 后面不要逗号
isnull不要空格。
你要看看语法
SELECT t1.*,(case
when isnull(a3.F_AAA_REMARKS,'')<>'' then a3.F_AAA_REMARKS
when isnull(a4.F_AAA_REMARKS,'')<>'' then a4.F_AAA_REMARKS
when isnull(a5.FCOMMENT,'')<>'' then a5.FCOMMENT
when isnull(a6.FNote,'')<>'' then a6.FNote else '' end FRemarksintoTMP3707BF8A9D2011E7B195005056EFROMTMP3707BF8B9D2011E7B195005056E
#18
都有空格的,现在提示isnull后有错误
when then 后面不要逗号
isnull不要空格。
你要看看语法
SELECT t1.*,(case
when isnull(a3.F_AAA_REMARKS,'')<>'' then a3.F_AAA_REMARKS
when isnull(a4.F_AAA_REMARKS,'')<>'' then a4.F_AAA_REMARKS
when isnull(a5.FCOMMENT,'')<>'' then a5.FCOMMENT
when isnull(a6.FNote,'')<>'' then a6.FNote else '' end FRemarksintoTMP3707BF8A9D2011E7B195005056EFROMTMP3707BF8B9D2011E7B195005056E
string strsql = "/*dialect*/SELECT t1.*,case when isnull(a3.F_AAA_REMARKS,'')<>'' then a3.F_AAA_REMARKS"
+ "when isnull(a4.F_AAA_REMARKS,'')<>'' then a4.F_AAA_REMARKS"
+ "when isnull(a5.FCOMMENT,'')<>'' then a5.FCOMMENT"
+ "when isnull(a6.FNote,'')<>'' then a6.FNote else '' end FRemarks"
+ "into{0}"
+ "FROM{1} /*后台应收账款明细表的临时表*/ t1"
+ "left join t_AR_receivable a3 on t1.FFORMID='AP_receivable' and t1.fid=a3.fid"
+ "left join T_AR_OttherRecAble a4 on t1.FFORMID='T_AR_OttherRecAble' and t1.fid=a4.fid"
+ "left join T_AR_RECEIVEBILLENTRY a5 on a5.fformid='T_AR_RECEIVEBILLENTRY' and t1.fid=a5.fid and a5.FSEQ=1"
+ "left join T_AR_REFUNDBILLENTRY a6 on t1.fformid='T_AR_REFUNDBILLENTRY' and t1.fid=a6.fid and a6.FSEQ=1";
第一眼看去,第三行 when 前面要有空格
<>'' then a4.F_AAA_REMARKSwhen is null(a5.FCOMMENT,'')<>'' then a5.FCOMMENT when is null(a6.FNote,'')
#2
看错了,sorry
#3
is null改成isnull
#4
楼主是不是这个意思
SELECT t1.*,case when isnull(a3.F_AAA_REMARKS,'')<>'' then a3.F_AAA_REMARKS
when a3.F_AAA_REMARKS isnull(a4.F_AAA_REMARKS,'')<>'' then a4.F_AAA_REMARKS
when a4.F_AAA_REMARKS isnull(a5.FCOMMENT,'')<>'' then a5.FCOMMENT
when a5.FCOMMENT isnull(a6.FNote,'')<>'' then a6.FNote
else '' end from
t1 left join t_AR_receivable a3 on t1.FFORMID='AP_receivable' and t1.fid=a3.fid
left join T_AR_OttherRecAble a4 on t1.FFORMID='T_AR_OttherRecAble' and t1.fid=a4.fid
left join T_AR_RECEIVEBILLENTRY a5 on a5.fformid='T_AR_RECEIVEBILLENTRY' and t1.fid=a5.fid and a5.FSEQ=1
left join T_AR_REFUNDBILLENTRY a6 on t1.fformid='T_AR_REFUNDBILLENTRY' and t1.fid=a6.fid and a6.FSEQ=1
#5
is null改成isnull
原来是isnull的,报错了,我才改为is null
#6
楼主是不是这个意思
SELECT t1.*,case when isnull(a3.F_AAA_REMARKS,'')<>'' then a3.F_AAA_REMARKS
when a3.F_AAA_REMARKS isnull(a4.F_AAA_REMARKS,'')<>'' then a4.F_AAA_REMARKS
when a4.F_AAA_REMARKS isnull(a5.FCOMMENT,'')<>'' then a5.FCOMMENT
when a5.FCOMMENT isnull(a6.FNote,'')<>'' then a6.FNote
else '' end from
t1 left join t_AR_receivable a3 on t1.FFORMID='AP_receivable' and t1.fid=a3.fid
left join T_AR_OttherRecAble a4 on t1.FFORMID='T_AR_OttherRecAble' and t1.fid=a4.fid
left join T_AR_RECEIVEBILLENTRY a5 on a5.fformid='T_AR_RECEIVEBILLENTRY' and t1.fid=a5.fid and a5.FSEQ=1
left join T_AR_REFUNDBILLENTRY a6 on t1.fformid='T_AR_REFUNDBILLENTRY' and t1.fid=a6.fid and a6.FSEQ=1
SELECT t1.*,case when isnull(a3.F_AAA_REMARKS,'')<>'' then a3.F_AAA_REMARKS,when isnull(a4.F_AAA_REMARKS,'')<>'' then a4.F_AAA_REMARKS,when isnull(a5.FCOMMENT,'')<>'' then a5.FCOMMENT,when isnull(a6.FNote,'')<>'' then a6.FNote else '' end FRemarksintoTMP3707BF8A9D2011E7B195005056EFROMTMP3707BF8B9D2011E7B195005056E /*后台应收账款明细表的临时表*/ t1left join t_AR_receivable a3 on t1.FFORMID='AP_receivable' and t1.fid=a3.fidleft join T_AR_OttherRecAble a4 on t1.FFORMID='T_AR_OttherRecAble' and t1.fid=a4.fidleft join T_AR_RECEIVEBILLENTRY a5 on a5.fformid='T_AR_RECEIVEBILLENTRY' and t1.fid=a5.fid and a5.FSEQ=1left join T_AR_REFUNDBILLENTRY a6 on t1.fformid='T_AR_REFUNDBILLENTRY' and t1.fid=a6.fid and a6.FSEQ=1
#10
如果是 Oracle 的话可以用 nvl()
sql server 2012的数据库
#11
已经提示你啦
is null(a6.FNote,'') 你应该是想要 isnull(a6.FNote,'') 多了空格
//对初步的查询结果进行处理,然后写回基类默认的存放查询结果的临时表
StringBuilder sb = new StringBuilder();
string strsql = "/*dialect*/SELECT t1.*,case when isnull(a3.F_AAA_REMARKS,'')<>'' then a3.F_AAA_REMARKS,"
+ "when isnull(a4.F_AAA_REMARKS,'')<>'' then a4.F_AAA_REMARKS,"
+ "when isnull(a5.FCOMMENT,'')<>'' then a5.FCOMMENT,"
+ "when isnull(a6.FNote,'')<>'' then a6.FNote else '' end FRemarks"
+ "into{0}"
+ "FROM{1} /*后台应收账款明细表的临时表*/ t1"
+ "left join t_AR_receivable a3 on t1.FFORMID='AP_receivable' and t1.fid=a3.fid"
+ "left join T_AR_OttherRecAble a4 on t1.FFORMID='T_AR_OttherRecAble' and t1.fid=a4.fid"
+ "left join T_AR_RECEIVEBILLENTRY a5 on a5.fformid='T_AR_RECEIVEBILLENTRY' and t1.fid=a5.fid and a5.FSEQ=1"
+ "left join T_AR_REFUNDBILLENTRY a6 on t1.fformid='T_AR_REFUNDBILLENTRY' and t1.fid=a6.fid and a6.FSEQ=1";
#12
你这表名好长啊,from呢
from FRemarksintoTMP3707BF8A9D2011E7B195005056EFROMTMP3707BF8B9D2011E7B195005056E
#13
看到了,你没加空格,都一起了
"into {0}"
+ "FROM {1}
#14
看到了,你没加空格,都一起了
"into {0}"
+ "FROM {1}
哪里错了呀,、求指点?
#15
+ " FROM {1} /*后台应收账款明细表的临时表*/ t1"
+ " left join t_AR_receivable a3 on t1.FFORMID='AP_receivable' and t1.fid=a3.fid"
+ " left join T_AR_OttherRecAble a4 on t1.FFORMID='T_AR_OttherRecAble' and t1.fid=a4.fid"
+ " left join T_AR_RECEIVEBILLENTRY a5 on a5.fformid='T_AR_RECEIVEBILLENTRY' and t1.fid=a5.fid and a5.FSEQ=1"
+ " left join T_AR_REFUNDBILLENTRY a6 on t1.fformid='T_AR_REFUNDBILLENTRY' and t1.fid=a6.fid and a6.FSEQ=1";
空格!单词间要有空格
#16
都有空格的,现在提示isnull后有错误
#17
都有空格的,现在提示isnull后有错误
when then 后面不要逗号
isnull不要空格。
你要看看语法
SELECT t1.*,(case
when isnull(a3.F_AAA_REMARKS,'')<>'' then a3.F_AAA_REMARKS
when isnull(a4.F_AAA_REMARKS,'')<>'' then a4.F_AAA_REMARKS
when isnull(a5.FCOMMENT,'')<>'' then a5.FCOMMENT
when isnull(a6.FNote,'')<>'' then a6.FNote else '' end FRemarksintoTMP3707BF8A9D2011E7B195005056EFROMTMP3707BF8B9D2011E7B195005056E
#18
都有空格的,现在提示isnull后有错误
when then 后面不要逗号
isnull不要空格。
你要看看语法
SELECT t1.*,(case
when isnull(a3.F_AAA_REMARKS,'')<>'' then a3.F_AAA_REMARKS
when isnull(a4.F_AAA_REMARKS,'')<>'' then a4.F_AAA_REMARKS
when isnull(a5.FCOMMENT,'')<>'' then a5.FCOMMENT
when isnull(a6.FNote,'')<>'' then a6.FNote else '' end FRemarksintoTMP3707BF8A9D2011E7B195005056EFROMTMP3707BF8B9D2011E7B195005056E
string strsql = "/*dialect*/SELECT t1.*,case when isnull(a3.F_AAA_REMARKS,'')<>'' then a3.F_AAA_REMARKS"
+ "when isnull(a4.F_AAA_REMARKS,'')<>'' then a4.F_AAA_REMARKS"
+ "when isnull(a5.FCOMMENT,'')<>'' then a5.FCOMMENT"
+ "when isnull(a6.FNote,'')<>'' then a6.FNote else '' end FRemarks"
+ "into{0}"
+ "FROM{1} /*后台应收账款明细表的临时表*/ t1"
+ "left join t_AR_receivable a3 on t1.FFORMID='AP_receivable' and t1.fid=a3.fid"
+ "left join T_AR_OttherRecAble a4 on t1.FFORMID='T_AR_OttherRecAble' and t1.fid=a4.fid"
+ "left join T_AR_RECEIVEBILLENTRY a5 on a5.fformid='T_AR_RECEIVEBILLENTRY' and t1.fid=a5.fid and a5.FSEQ=1"
+ "left join T_AR_REFUNDBILLENTRY a6 on t1.fformid='T_AR_REFUNDBILLENTRY' and t1.fid=a6.fid and a6.FSEQ=1";