select isnull(a.dtdate,b.dtdate) as dtdate,
a.mReceipt,
b.mpay,
(isnull(a.mReceipt,0)-isnull(b.mpay,)) as mreplus,
isnull(a.neptpk,b.neptpk) as ndeptpk
from table1 a full join table2 b on a.nDeptPK=b.nDeptPK and a.dtDate=b.dtDate
group by isnull(a.dtdate,b.dtdate),isnull(a.neptpk,b.neptpk)
a.mReceipt,
b.mpay,
(isnull(a.mReceipt,0)-isnull(b.mpay,)) as mreplus,
isnull(a.neptpk,b.neptpk) as ndeptpk
from table1 a full join table2 b on a.nDeptPK=b.nDeptPK and a.dtDate=b.dtDate
group by isnull(a.dtdate,b.dtdate),isnull(a.neptpk,b.neptpk)
解决方案 »
- 简单的SQL语句询问
- 一个MSSQL2005的数据库可以允许多少个站点同时链接
- 性能计数器注册表配置单元一致性失败
- 急急如律令请教:查询语句包含表名或函数名过多,超过最大256数目?
- 求一条sql查询语句
- 我想从数据库、患者基本信息表中归类,请高手帮忙写下SQL语句
- 怎樣來創建表A中的ID號等於0001的視圖?
- 哪位高手列一下现在流行的各个SQL语言标准或版本,能提供教程者另有分相送
- 立即送50分!!! 如何用让存储过程返回一个RECORDSET?
- MS Server SQL case when 判断条件问题
- 请教关于现有库各表结构及相关索引、存储过程等复制的方法
- 一个表中的子段来自另一个表的记录ID,而且是复选,怎么设计比较好?
as
select isnull(a.dtdate,b.dtdate) as dtdate,
a.mReceipt,
b.mpay,
(isnull(a.mReceipt,0)-isnull(b.mpay,)) as mreplus,
isnull(a.neptpk,b.neptpk) as ndeptpk
from table1 a full join table2 b on a.nDeptPK=b.nDeptPK and a.dtDate=b.dtDate
group by isnull(a.dtdate,b.dtdate),isnull(a.neptpk,b.neptpk)
服务器: 消息 8120,级别 16,状态 1,行 8
列 'b.mMoney' 在选择列表中无效,因为该列既不包含在聚合函数中,也不包含在 GROUP BY 子句中。
服务器: 消息 8120,级别 16,状态 1,行 8
列 ' a.mPay'在选择列表中无效,因为该列既不包含在聚合函数中,也不包含在 GROUP BY 子句中。
as
select isnull(a.dtdate,b.dtdate) as dtdate,
a.mReceipt,
b.mpay,
(isnull(a.mReceipt,0)-isnull(b.mpay,)) as mreplus,
isnull(a.neptpk,b.neptpk) as ndeptpk
from table1 a full join table2 b on a.nDeptPK=b.nDeptPK and a.dtDate=b.dtDate
去掉 group by 那一行