易截截图软件、单文件、免安装、纯绿色、仅160KB

SQL Server 合并结果集 - MS-SQL Server / 疑难问题

select b.AccountantID,dbo.hidtelpart(a.tel),midreceivedate,
isnull(c.enddate,Dateadd(yy,1,midreceivedate)) as enddate,
b.bankdate ,a.amount,DateDiff(mm,midreceivedate,enddate)as m
from dbo.AccountantFinal as a
 join dbo.Accountant as b on a.SourceID=b.AccountantID
 --join CustomerExtend as c on a.tel=c.tel
 join dbo.AccountReport as c on a.AccountantID=c.AccountantFinalID
 where DateDiff(mm,getdate(),b.BankDate)=0  
 

select Amount,AccountantID from dbo.Accountant 
where AccountantID not in (select SourceID from dbo.AccountantFinal ) 
and DateDiff(mm,getdate(),BankDate)=0

select Amount,AccountantID,b.num,Amount-b.num from dbo.Accountant as a join (
select SUM(Amount) as num,SourceID from dbo.AccountantFinal 
where DATEDIFF(mm,GetDate(),ReceiveDate)>=-3 group by SourceID) as b on a.AccountantID=b.SourceID
 and a.Amount>b.num
 where DateDiff(mm,getdate(),a.BankDate)=0 



这三条SQL语句和并成为存储过程 
要求
显示列以第一条为主 第一条没有的话添加上去
没有数据的显示为空
union all

SQL code:
select a.*, b.* , c.* from a left outer join b on a.**** = b.**** left outer join c on a.**** = c.****
弄个别名 再嵌套查呗

合并:union all&nb


相关问答:

jsp链接sql2000的疑问?



type Exception report


message

description The server encountered an internal error () that prevented it from fulfilling this request.

exception

org.apache.jas ......

Asp+sql server问题 - Web 开发 / ASP

我一个项目,有个插入操作,具体是这样的:
我有进货信息表。在出货时选择相应的进货信息,输入数量,选择部门后,点保存按钮,由于网络延时,点一下没有反映,于是用户就又点一下,导致一次插入了两条记录:
例: ......

MS SQL作业问题 - MS-SQL Server / 应用实例

如何在SQL2005中设定定时作业,比如说定时清理某些表的数据,
或者是定时的将某些表的数据导出excel!
在线等待,急急急,最好是详细步骤!
之前我做的作业有点问题!
帮UP

参考:http://hi.baidu.com/toiota ......

求一SQL - MS-SQL Server / 基础类

tab1 字段:billdate,goodsid,incount,inmoney,outcount,outmoney,endprice,endcount,endamt
tab2 字段:goodsid,goodskind(商品类型)
tab3 字段:goodskind(商品类型),kindname
结果:
得到商品类型在一段时间 ......

求一个SQL语句 - MS-SQL Server / 基础类

字段1,字段2.....字段N,Status,ParentID
1,Name1....test1,1,99
1,Name1....test1,3,99
1,Name2....test2,1,101
1,Name2....test2,3,101
1,Name3....test3,2,101
1,Name1....test1,4,101
想要的结果是:
1,Na ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号