动态行列转换问题?sqlserver中能执行,到access中就执行不了!郁闷

jxf_yx 2005-02-23 10:53:04
Revenue表:
accountid amount date
1 123 2004-01-11
1 232 2004-01-12
2 4023 2004-07-11
3 423 2004-07-25
4 423 2004-12-11
..
..
==
Account表:
ID Name
1 薪水
2 吃喝 
3 其它收入
4 游玩
..
..
===================================
select 名称=c.Name,时间=a.月份,数量=isnull(sum(b.amount),0)
from(
select a.accountid,b.m,b.月份 from(
select accountid from revenue )a,(
select m=1 ,月份='1' union all
select m=2 ,月份='2' union all
select m=3 ,月份='3' union all
select m=4 ,月份='4' union all
select m=5 ,月份='5' union all
select m=6 ,月份='6' union all
select m=7 ,月份='7' union all
select m=8 ,月份='8' union all
select m=9 ,月份='9' union all
select m=10,月份='10' union all
select m=11,月份='11' union all
select m=12,月份='12')b
)a left join revenue b on a.accountid=b.accountid
and a.m=month(b.date)
left join account c on a.accountid=c.id group by c.id,c.Name,a.月份,a.m
order by c.ID,a.m
上面的sql语句在sql server中执行无问题,到access中,就提示:
“语法错误(操作符丢失)在查询表达式''中
====
有没有人对access的jet-sql熟悉的。
...全文
339 20 打赏 收藏 转发到动态 举报
写回复
用AI写文章
20 条回复
切换为时间正序
请发表友善的回复…
发表回复
moon15 2005-05-11
  • 打赏
  • 举报
回复
帮你up
jxf_yx 2005-03-18
  • 打赏
  • 举报
回复
up
jxf_yx 2005-03-09
  • 打赏
  • 举报
回复
up
天地客人 2005-03-01
  • 打赏
  • 举报
回复
access中没有union,你把查询的结果放到一个新的临时表中吧,再对临时表操作!
jxf_yx 2005-03-01
  • 打赏
  • 举报
回复
up
jxf_yx 2005-02-26
  • 打赏
  • 举报
回复
up
jxf_yx 2005-02-25
  • 打赏
  • 举报
回复
难道就没解决方法了,难到在access中就不能做出这样的查询了吗???
jinjazz 2005-02-24
  • 打赏
  • 举报
回复
access中就没有办法了
dzhfly 2005-02-24
  • 打赏
  • 举报
回复
有很多语法,都不能在acc里用insert ... from 也不行
jxf_yx 2005-02-24
  • 打赏
  • 举报
回复
那 zjcxc(邹建) 大哥,我想在access中实现这样的效果有什么办法?难道就不能查询了吗?
zjcxc 元老 2005-02-24
  • 打赏
  • 举报
回复
ACCESS不支持这样拼出的表集

select m=1 ,月份='1' union all
select m=2 ,月份='2' union all
.....
jxf_yx 2005-02-24
  • 打赏
  • 举报
回复
up
jxf_yx 2005-02-24
  • 打赏
  • 举报
回复
up
lsftest 2005-02-24
  • 打赏
  • 举报
回复
文本字段在sql server里用''括起来,但在access中要用""
改改试试。。。
jxf_yx 2005-02-23
  • 打赏
  • 举报
回复
不是,那个错误,access中有isnull函数的。你可以试试。
didoleo 2005-02-23
  • 打赏
  • 举报
回复
可能access里没有isnull函数吧,你试试用
iif(sum(b.amount)=null,0,sum(b.amount)) 来代替
isnull(sum(b.amount),0)
jxf_yx 2005-02-23
  • 打赏
  • 举报
回复
up
jxf_yx 2005-02-23
  • 打赏
  • 举报
回复
对,isnull是错误,不过错误不是那里。
用iif(sum(b.amount)=null,0,sum(b.amount))
或者直接sum(b.amount)

还是那个错误。
试了好多地方,就是找不到错误在哪里
didoleo 2005-02-23
  • 打赏
  • 举报
回复
--isnull(sum(b.amount),0)

查了一下access的联机帮助,access的isnull函数只能有一个参数,而且他的含义不象sql server那样,
他只是判断是不是null值.

jxf_yx 2005-02-23
  • 打赏
  • 举报
回复
up

34,576

社区成员

发帖
与我相关
我的任务
社区描述
MS-SQL Server相关内容讨论专区
社区管理员
  • 基础类社区
  • 二月十六
  • 卖水果的net
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧