首页 > 代码库 > C#后台sql语句注释,根据isnull()方法进行条件选择
C#后台sql语句注释,根据isnull()方法进行条件选择
select isnull(b.guid,k.guid) as project_id,isnull(b.projectno,k.projectno) as projectno,
isnull(b.projectname,k.projectname) as projectname,c.COMPANYNAME as customer,
isnull(b.project_date,k.project_date) as project_date,d.typecn,a.guid as apply_id,a.applyname,e.applyCreditAmt,
sum(isnull(f.payamount,0)) payamount,f.paydate,g.name as pay_user,h.name as saler,j.typecn as approval_status,
isnull(b.CREATE_TIME,k.CREATE_TIME) as bcreate_time,a.create_time as acreate_time,
(case when b.guid is null then ‘zl‘ else ‘bl‘ end) as projectType into #tbl
from dbo.ffs_projectapply a
left join ffs_project b on a.PROJECTID=b.guid
left join FFS_ProjectLease k on a.projectid=k.guid
left join ffs_customer c on c.guid=isnull(b.customerid,k.customerid)
left join ffs_publicelement d on d.code=isnull(b.project_type,k.project_type) and d.type=‘project_type‘
left join FFS_PAYMENT e on e.projectapplyid=a.guid
left join FFS_PAYMENTDETAIL f on f.projectapplyid=a.guid
left join IFS_USER g on g.guid=f.payopuser
left join IFS_USER h on h.guid=a.saler_id
left join FFS_CustomerRefsaler i on i.customer_id=isnull(b.customerid,k.customerid) and i.recordstatus=‘A‘
left join ffs_publicelement j on j.code=a.recordstatus and j.type=‘ProjectApply_Status‘
where isnull(b.project_date,k.project_date) between ‘2017-01-25‘ and ‘2017-04-26‘ --and b.project_type in(‘001‘,‘002‘,‘003‘,‘004‘,‘005‘)
and a.recordstatus=‘Payed‘ and isnull(b.recordstatus,k.recordstatus)=‘Approved‘
蓝色标记 处中,利用是isnull()方法巧妙的进行选择on的条件;
红色标记处中,该段sql语句是写在C#后台中,利用"--"来进行注释
C#后台sql语句注释,根据isnull()方法进行条件选择