SQL 日期跟時間的欄位合併後的查詢
將日期跟時間的欄位合併後 存在temp
再用between做搜尋
再用between做搜尋
with temp as ( SELECT convert(char(11),Date)+convert(char(8),ImportTime) as DateTime,Symbol,Price FROM Stock WITH (nolock) Where (Date between '2014-02-26' and '2014-02-27') and Symbol = '1101' ) SELECT DateTime,Symbol,Price from temp Where DateTime BETWEEN '2014-02-26 10:00:00' AND '2014-02-27 11:00:00' order by DateTime
留言
張貼留言