通常:

select YMD + ' ' + HM as DateTime
from Table
where ( YMD >= '20050201'
    
and YMD <= '20050201' )


发现:

select YMD + ' ' + HM as DateTime
from Table
where  YMD + HM >=  '200502010204'

还可以这样:

SELECT
   
CASE 
      
WHEN price IS NULL THEN 'Not yet priced'
      
WHEN price < 10 THEN 'Very Reasonable Title'
      
WHEN price >= 10 and price < 20 THEN 'Coffee Table Title'
      
ELSE 'Expensive book!'
   
END AS "Price Category",
CONVERT(varchar(20), title) AS "Shortened Title"
FROM pubs.dbo.titles
ORDER BY price