select A.c_A1,A.c_A2,B.c_B2,
isnull(sum(case when n_bz=2 then C.n_je end),0) as n_1,
isnull(sum(case when n_bz=3 and YEAR(d_rq)='2006' then C.n_je end),0) as n_2,
isnull(sum(case when n_bz=0 then C.n_je end),0) as n_3,
isnull(sum(case when n_bz=1 then C.n_je end),0) as n_4
from C,B,D LEFT OUTER JOIN A where C.c_B1=B.c_B1 and
C.c_D=D.c_D and C.c_A=A.c_A
and C.d_rq>='2006.01.01' and C.d_rq<='2006.07.12' and C.c_B1='02' and C.c_D='02'
group by A.c_A,A.c_A2,B.c_B2 order by A.c_A2总提示
在关键字 'where' 附近有语法错误。
不知道该怎样写?
isnull(sum(case when n_bz=2 then C.n_je end),0) as n_1,
isnull(sum(case when n_bz=3 and YEAR(d_rq)='2006' then C.n_je end),0) as n_2,
isnull(sum(case when n_bz=0 then C.n_je end),0) as n_3,
isnull(sum(case when n_bz=1 then C.n_je end),0) as n_4
from C,B,D LEFT OUTER JOIN A where C.c_B1=B.c_B1 and
C.c_D=D.c_D and C.c_A=A.c_A
and C.d_rq>='2006.01.01' and C.d_rq<='2006.07.12' and C.c_B1='02' and C.c_D='02'
group by A.c_A,A.c_A2,B.c_B2 order by A.c_A2总提示
在关键字 'where' 附近有语法错误。
不知道该怎样写?
解决方案 »
- 如何分组各取12条数据
- 将数据导出为excel时,对于文本字符,就要前面加上单引号,但是如果让这个单引号在excel中不显示呢?
- 关于批量、游标的一些问题
- 查询的记录老是不随着参数变化的问题
- MS Sql 7.0 中Text类型字段截断字段内容的问题?
- sql server 2005 技术内幕 存储引擎191页的问题
- 关于sql数据库触发器的一些问题,望有大牛能不吝赐教
- 寻求一个SQL查询语句或者一个存储过程(有关中转站查询)
- 【急!!】SQLSERVER UPDATE超时问题~~~
- “exists” 和 “count(*)”的区别???
- 一个简单语句,用SELECT筛选出一列递增数字中的最小缺少值的语句,高分请教!
- 请教不同的数据库中数据的查询问题
isnull(sum(case when n_bz=2 then C.n_je end),0) as n_1,
isnull(sum(case when n_bz=3 and YEAR(d_rq)='2006' then C.n_je end),0) as n_2,
isnull(sum(case when n_bz=0 then C.n_je end),0) as n_3,
isnull(sum(case when n_bz=1 then C.n_je end),0) as n_4
from C inner join B on C.c_B1=B.c_B1
inner join D on C.c_D=D.c_D
LEFT OUTER JOIN A on C.c_A=A.c_A
where C.d_rq>='2006.01.01' and C.d_rq<='2006.07.12' and C.c_B1='02' and C.c_D='02'
group by A.c_A,A.c_A2,B.c_B2 order by A.c_A2
但 Join 的链接条件用的是 on 而不是在where中写的