| 发表于:2007-06-25 11:04:218楼 得分:0 |
lwl0606(寒泉) ( ) : 自己后来解决了,你的方法有漏洞,就是碰到闰年的情况,两月分可能天数有变化,转换的时候就错误。 create view dbo.bp_bpdd_bpi as select bpdd.precode,bpdd.productid,bpdd.productrelation1,bpdd.productrelation2,bpdd.exchangekind,(bpdd.rate*bpdd.qvalue) as qvalue,bpdd.tax,bpdd.saleprice,bpdd.profit,bpdd.remark, bp.customername,bp.creattime,bpi.place1,bpi.place2,bpi.place3,bpi.place4, bpi.place5, bpi.carrier1 ,bpi.carrier2,bpi.carrier3,bpi.carrier4,bpi.class1,bpi.class2,bpi.class3,bpi.class4, bpi.flight1, bpi.flight2,bpi.flight3,bpi.flight4, bpi.date1,isnull(bpi.tourcode, ' ') as tourcode ,bp.grup,bpdd.inprice,bpdd.outprice , case substring(bpi.date1,3,3) when 'jan ' then '190001 '+substring(date1,1,2) when 'feb ' then '190002 '+substring(date1,1,2) when 'mar ' then '190003 '+substring(date1,1,2) when 'apr ' then '190004 '+substring(date1,1,2) when 'may ' then '190005 '+substring(date1,1,2) when 'jun ' then '190006 '+substring(date1,1,2) when 'jul ' then '190007 '+substring(date1,1,2) when 'aug ' then '190008 '+substring(date1,1,2) when 'sep ' then '190009 '+substring(date1,1,2) when 'oct ' then '190010 '+substring(date1,1,2) when 'nov ' then '190011 '+substring(date1,1,2) when 'dec ' then '190012 '+substring(date1,1,2) end as dateorder from billpayproductdtl bpdd inner join billpayproduct bp on bp.billno=bpdd.billno inner join billpayiticket bpi on bpi.bookpid=bpdd.bookpid and len(bpi.date1)=5 union all select bpdd.precode,bpdd.productid,bpdd.productrelation1,bpdd.productrelation2,bpdd.exchangekind,(bpdd.rate*bpdd.qvalue) as qvalue,bpdd.tax,bpdd.saleprice,bpdd.profit,bpdd.remark, bp.customername,bp.creattime,bpoi.place1,bpoi.place2,bpoi.place3,bpoi.place4, bpoi.place5, bpoi.carrier1 ,bpoi.carrier2,bpoi.carrier3,bpoi.carrier4,bpoi.class1,bpoi.class2,bpoi.class3,bpoi.class4, bpoi.flight1, bpoi.flight2,bpoi.flight3,bpoi.flight4, bpoi.date1,isnull(bpoi.tourcode, ' ') as tourcode , bp.grup,bpdd.inprice,bpdd.outprice ,case substring(bpoi.date1,3,3) when 'jan ' then '190001 '+substring(date1,1,2) when 'feb ' then '190002 '+substring(date1,1,2) when 'mar ' then '190003 '+substring(date1,1,2) when 'apr ' then '190004 '+substring(date1,1,2) when 'may ' then '190005 '+substring(date1,1,2) when 'jun ' then '190006 '+substring(date1,1,2) when 'jul ' then '190007 '+substring(date1,1,2) when 'aug ' then '190008 '+substring(date1,1,2) when 'sep ' then '190009 '+substring(date1,1,2) when 'oct ' then '190010 '+substring(date1,1,2) when 'nov ' then '190011 '+substring(date1,1,2) when 'dec ' then '190012 '+substring(date1,1,2) end as dateorder from billpayproductdtl bpdd inner join billpayproduct bp on bp.billno=bpdd.billno inner join billpayoutiticket bpoi on bpoi.bookpid=bpdd.bookpid and len(bpoi.date1)=5 这样就变成字符串比较了,比较笨不过办法可行! | | |
|