数据表字段 N Y R
想要查询时做比较 select * from table where N-Y-R >= ‘2012-9-6’
类似这样 就是不知道NYR该怎样合并才能做比较
遂求助!
------解决方案--------------------
- SQL code
-->测试数据declare @table table([N] int,[Y] int,[R] int)insert into @tableselect '2012','08','20' union allselect '2012','09','05' union allselect '2012','09','06' --select * from @table-->测试查询select convert(varchar,[N])+'-'+convert(varchar,[Y])+'-'+convert(varchar,[R])as 日期 from @table where convert(varchar,[N])+'-'+convert(varchar,[Y])+'-'+convert(varchar,[R])<= convert(varchar,'2012-9-6')-->测试结果/*---------------------------------------日期2012-8-202012-9-52012-9-6*/