sql查询语句,在线等,解决马上结贴
select *,'班次'=(iif(warnTime.value>'2012-06-26 09:30:00','a','b')) from warningrecord where [date]='2012-6-26'
查询一个表,在查出整个表格的基础上增加一个字段“班次”,根据表格内的一个字段warnTime.value的值判断给‘班次’赋值
if warnTime.value<"2012-06-26 09:30:00" then 班次=‘a’
if warnTime.value<"2012-06-26 17:30:00" and warnTime.value>"2012-06-26 9:30:00" then 班次=‘b’
if warnTime.value>"2012-06-26 17:30:00" then 班次=‘c’
[解决办法]
Dim sql As String
sql = "select *,(case when '" & warnTime.Text & "'<'2012-06-26 09:30:00' then 'a'" & _
" when '" & warnTime.Text & "' between '2012-06-26 17:30:00' and '2012-06-26 9:30:00' then 'b'" & _
" else 'c') 班次" & _
" from warningrecord where [date]='2012-6-26'"