急,有关SQL连接问题!!!!!!

amwip110 2008-02-20 11:03:47
set rowcount 100
select a.sStoreNO,a.nGoodsID,(b.nTotalSaleAmount-a.nTotalSaleAmount) as '金额',(b.nTotalSaleQty-a.nTotalSaleQty) as '销量'
from tGoodsDaily as a ,tGoodsDaily as b
where a.sStoreNO='C503' and b.sStoreNO='C503' and a.dTradeDate = '20080218' and b.dTradeDate='20080219' and a.nGoodsID=b.nGoodsID
group by nGoodsID
order by (b.nTotalSaleAmount-a.TotalSaleQty) desc
set rowcount 0
报错:Server Message: Number 209, Severity 16
Server 'TONGCHENGSRVE', Line 2:
Ambiguous column name nGoodsID
Server Message: Number 207, Severity 16
Server 'TONGCHENGSRVE', Line 2:
Invalid column name 'TotalSaleQty'.

请高手指点!!!
...全文
28 点赞 收藏 1
写回复
1 条回复
切换为时间正序
当前发帖距今超过3年,不再开放新的回复
发表回复
kk19840210 2008-02-20
set rowcount 100
select a.sStoreNO,a.nGoodsID,(b.nTotalSaleAmount-a.nTotalSaleAmount) as '金额',(b.nTotalSaleQty-a.nTotalSaleQty) as '销量'
from tGoodsDaily as a ,tGoodsDaily as b
where a.sStoreNO='C503' and b.sStoreNO='C503' and a.dTradeDate = '20080218' and b.dTradeDate='20080219' and a.nGoodsID=b.nGoodsID
group by nGoodsID --是否明确为 A 或 B 的nGoodsID 列order by (b.nTotalSaleAmount-a.TotalSaleQty) desc --列名是否写错 b.nTotalSaleQty-a.nTotalSaleQtyset rowcount 0
回复
相关推荐
基于java的企业人事管理系统设计--软件工程课程设计(含源码与论文设计).rar 1 引言 4 1.1 课程设计目标 4 1.2 编程工具(编程环境)介绍 4 1.3 实施时间及主要实施步骤 4 2 需求分析 5 3 系统总体设计 6 4 数据库设计 6 5 主要功能模块的设计与实现 10 5.1 功能模块1详细设计(综合查询员工信息)..........................................................10 5.1.1 详细设计.......................................................................................................10 5.1.2 算法流程........................................................................................................15 5.1.3 界面设计及测试结果.....................................................................................15 6 调试分析 15 7 用户手册 16 8 测试结果 17 8.1 员工信息的添加...................................................................................................17 8.2 员工信息的修改...................................................................................................17 8.3 员工信息的删除...................................................................................................18 8.4 员工信息的综合查询...........................................................................................18 8.5 员工信息按性别统计的结果................................................................................19 8.6 员工信息按状态统计的结果...............................................................................19 8.7 员工信息按职称统计的结果................................................................................20 9 结论 20 10 参考文献 20
发帖
MS-SQL Server
创建于2007-09-28

3.3w+

社区成员

MS-SQL Server相关内容讨论专区
申请成为版主
帖子事件
创建了帖子
2008-02-20 11:03
社区公告
暂无公告