select a.客户名称, a.本月用邮费用 , b.上月用邮费用,(a.本月用邮费用-b.上月用邮费用)/b.上月用邮费用 as 增减百分比
from
(
select customer_org.customer_name as 客户名称,sum(Saleslog.income) as 本月用邮费用
from customer_org, Saleslog
where Saleslog.salestime>='3/1/2002' and Saleslog.customer_id=customer_org.customer_id
group by customer_org.customer_name
) as a full join
(
select customer_org.customer_name as 客户名称,sum(Saleslog.income) as 上月用邮费用
from customer_org, Saleslog
where Saleslog.salestime>='2/1/2002' and Saleslog.customer_id=customer_org.customer_id
group by customer_org.customer_name
) as b
on a.客户名称=b.客户名称分别执行 a ,b都没有错,为什么合在一起就不行?是不是full join 有问题,也不象是有问题啊?
我是在delphi的sql explore 里执行的
错误提示:提示
Invalid use of keyword
token:select
line number:4
from
(
select customer_org.customer_name as 客户名称,sum(Saleslog.income) as 本月用邮费用
from customer_org, Saleslog
where Saleslog.salestime>='3/1/2002' and Saleslog.customer_id=customer_org.customer_id
group by customer_org.customer_name
) as a full join
(
select customer_org.customer_name as 客户名称,sum(Saleslog.income) as 上月用邮费用
from customer_org, Saleslog
where Saleslog.salestime>='2/1/2002' and Saleslog.customer_id=customer_org.customer_id
group by customer_org.customer_name
) as b
on a.客户名称=b.客户名称分别执行 a ,b都没有错,为什么合在一起就不行?是不是full join 有问题,也不象是有问题啊?
我是在delphi的sql explore 里执行的
错误提示:提示
Invalid use of keyword
token:select
line number:4
解决方案 »
- Tedit丢失焦点的问题 大家来看下。。。。。。。。
- DELPHI7中字符转换成ASC的函数是什么?
- 请教:大家怎么对程序进行加密?CRC校验有用到过的吗?进来讲一下,来者有分!!
- 绘制统计图的问题!!!!!!!!!!!!!!!!!!!!!!!!!
- 如何判断Ini文件中Section的个数
- 高分求教QuickShape的用法(关于报表中绘制线条的问题)。不够再加分!
- 求fastreport for delphi6。在线等待!!在线结帐!!!
- 很急的问题,帮忙?
- 请问如何在form窗体刚启动时就锁定鼠标呢?
- delphi怎么把汉字转为GB2312,例如“武汉”变成%CE%E4%BA%BA
- ▲▲◎◎想交几个熟悉Devexpress公司产品的朋友,共同讨论,共同提高,请留下联系方式
- 如何将我的考勤人事系统与考勤机相连(高分相送)
from
后面的内容用括号括起来不行嘛?
一定帮你解决。
本版当然能够解决啦,只不过带星星的大牛没出现罢了。
把表结构脚本贴出来。
Saleslog.salestime>='2/1/2002' 这样写是不是有问题
第一个Select语句的a.* b.*都不对。
如果是本地表 .db dbf之流不支持as a ,as b那两句很正常
客户用邮记录 Saleslog
Log_ID 序号 char 10
customer_id 客户编号 char 15
customer_type 客户类型 Number 1
sales_time 用邮时间 Date
bsn_id 业务种类 char 6
unit_price 单价 Number 8.2
sales_count 业务量 Number 9.3
income 用邮费用 Number 9.3单位大客户 customer_org
customer_id 客户编号 Char 15
customer_name 客户名称 vc 80
admin_code 所在区域代码 Char 6
address 通信地址 vc 60
我这个sql怎么错了??你改成字母试试还是同样的错误,我本来from 后面用的就是临时表啊?
脚本的意思是
create table Saleslog
(...
)
有问题的应该是联合的问题,还有我测试下面语句在一条记录的时候没有错
select a.客户名称, a.本月用邮费用 , b.上月用邮费用,(a.本月用邮费用-b.上月用邮费用)/b.上月用邮费用 as 增减百分比
from
(
select customer_org.customer_name as 客户名称,sum(Saleslog.income) as 本月用邮费用
from customer_org, Saleslog
where Saleslog.salestime>=2002-03-01 and Saleslog.customer_id=customer_org.customer_id
group by customer_org.customer_name
) as a full join
(
select customer_org.customer_name as 客户名称,sum(Saleslog.income) as 上月用邮费用
from customer_org, Saleslog
where Saleslog.salestime>=2002-02-01 and Saleslog.customer_id=customer_org.customer_id
group by customer_org.customer_name
) as b
on a.客户名称=b.客户名称