日期:2014-05-18  浏览次数:20500 次

这样 为什么提示shrq无效?
SELECT a.Jydbh,  
  a.mddd,CONVERT(varchar(12) , a.Jhrq, 112 ) as shrq,
  a.Jhrq,
b.Clbh 

  FROM Jydxx as a left outer join Fhxx as b on a.Jydbh=b.Jydbh and 
  left(shrq,8) >= '20120403' and left(shrq,8) <= '20120408'

这样 为什么提示shrq无效

------解决方案--------------------
SQL code

SELECT 
    a.Jydbh,   
    a.mddd,CONVERT(varchar(12) , a.Jhrq, 112 ) as shrq,
    a.Jhrq,
    b.Clbh
FROM Jydxx as a 
left outer join Fhxx as b on a.Jydbh=b.Jydbh and  
--left(shrq,8) >= '20120403' and left(shrq,8) <= '20120408'
datediff(day, '2012-04-03', a.shrq)>=0 and datediff(day, '2012-04-08', a.shrq)<=0