日期:2014-05-17 浏览次数:20481 次
select a.gongsimc,a.card_kehu_no as kehu_no,a.card_no,a.card_kehu_mc as kehu_mc,a.card_kehu_shouji as kehu_dh,a.che_no,a.card_kind,a.card_enddate,lastdate,datediff(day,isnull(lastdate,getdate()-365),getdate()) days from (select zhifu_card_no,max(lastdate) as lastdate from (select zhifu_card_no ,xche_jsrq lastdate from work_pz_sj union select zhifu_card_no,xc_rq lastdate from work_xiche_pz_sj union select zhifu_card_no,xiao_rq lastdate from xiaosh_pz_sj union select card_no as zhifu_card_no,xche_jsrq lastdate from work_pz_sj union select card_no as zhifu_card_no,xc_rq lastdate from work_xiche_pz_sj union select card_no as zhifu_card_no,xiao_rq lastdate from xiaosh_pz_sj) aa group by zhifu_card_no) b left join card a on b.zhifu_card_no=a.card_no where a.card_no is not null and lastdate>='"&request("txtBeginDate")&"' and lastdate<='"&request("txtEndDate")&"' and a.GongSiNo = '"&request("gongsi")&"' and datediff(day,isnull(lastdate,getdate()-365),getdate())>='"&request("txtDay")&"' and datediff(day,isnull(lastdate,getdate()-365),getdate())<='"&request("txtDay2")&"' ORDER BY lastdate
select a.gongsimc,a.card_kehu_no as kehu_no,
a.card_no,a.card_kehu_mc as kehu_mc,
a.card_kehu_shouji as kehu_dh,
a.che_no,
a.card_kind,
a.card_enddate,
lastdate,
datediff(day,isnull(lastdate,getdate()-365),getdate()) days
from (
select zhifu_card_no,
max(lastdate) as lastdate
from (
select zhifu_card_no ,
xche_jsrq lastdate
from work_pz_sj
union
select zhifu_card_no,
xc_rq lastdate
from work_xiche_pz_sj
union
select zhifu_card_no,
xiao_rq lastdate
from xiaosh_pz_sj
union
select card_no as zhifu_card_no,
xche_jsrq lastdate
from work_pz_sj
union
select card_no as zhifu_card_no,
xc_rq lastdate
from work_xiche_pz_sj
union
select card_no as zhifu_card_no,
xiao_rq lastdate
from xiaosh_pz_sj
) aa
group by zhifu_card_no
) b
left join card a
on b.zhifu_card_no=a.card_no
where a.card_no is not null
and lastdate>='"&request("txtBeginDate")&"'
and lastdate<='"&request("txtEndDate")&"'
and datediff(day,isnull(lastdate,getdate()-365),getdate())>='"&request("txtDay")&"'
and datediff(day,isnull(lastdate,getdate()-365),