charindex(exp1,exp2) 返回第一个字符串位于第二个字符串的起始位
例如:
select charindex("wonderful", notes)
from titles
where title_id = "TC3218"
-----------
46
返回表达式wonderful在titles表中notes列上的起始位置。
select cardflag,state, avg(datediff (s, createtime,finaltime )),min( datediff(s ,createtime, finaltime)),max (datediff( s,createtime ,finaltime)) from do_card with(nolock ) where from_channel_child ='141160' and isfinal= 1 and createtime between '20141118' and '20141119' and cardflag in('chinaszx', 'chinaunicom','chinatelecom' ) and datediff(s ,createtime, finaltime)<'3600' and docount =1 and callerid <>0 group by cardflag, state order by cardflag ,state