要用在sqlserver中创建一个试图,但是提示from附近有语法错误 ,哪位大神给个正确语句出来???
CREATEVIEWdbo.view_log2ASSELECTDISTINCTl.f_CardRecordIDASID,l.f_CardNOASCardNo,l.f_Re...
CREATE VIEW dbo.view_log2
AS
SELECT DISTINCT
l.f_CardRecordID AS ID, l.f_CardNO AS CardNo, l.f_ReaderID AS rID,
l.f_Character AS ispass, r.f_ReaderName AS disc, l.f_ReadDate AS [time]
where l.f_ReadDate>to_date('2016/9/1 00:00:00','yyyy-mm-dd hh24:mi:ss') and l.f_ReadDate<to_date('2016/10/1 00:00:00','yyyy-mm-dd hh24:mi:ss')
FROM dbo.t_d_CardRecord l LEFT OUTER JOIN
dbo.v_b_Reader r ON l.f_ReaderID = r.f_ReaderID 展开
AS
SELECT DISTINCT
l.f_CardRecordID AS ID, l.f_CardNO AS CardNo, l.f_ReaderID AS rID,
l.f_Character AS ispass, r.f_ReaderName AS disc, l.f_ReadDate AS [time]
where l.f_ReadDate>to_date('2016/9/1 00:00:00','yyyy-mm-dd hh24:mi:ss') and l.f_ReadDate<to_date('2016/10/1 00:00:00','yyyy-mm-dd hh24:mi:ss')
FROM dbo.t_d_CardRecord l LEFT OUTER JOIN
dbo.v_b_Reader r ON l.f_ReaderID = r.f_ReaderID 展开
1个回答
展开全部
CREATE VIEW dbo.view_log2
AS
SELECT DISTINCT
l.f_CardRecordID AS ID ,
l.f_CardNO AS CardNo ,
l.f_ReaderID AS rID ,
l.f_Character AS ispass ,
r.f_ReaderName AS disc ,
l.f_ReadDate AS [time]
FROM dbo.t_d_CardRecord l
LEFT OUTER JOIN dbo.v_b_Reader r ON l.f_ReaderID = r.f_ReaderID
WHERE l.f_ReadDate > to_date('2016/9/1 00:00:00',
'yyyy-mm-dd hh24:mi:ss')
AND l.f_ReadDate < to_date('2016/10/1 00:00:00',
'yyyy-mm-dd hh24:mi:ss')
where条件要写在后面啊
追问
sql to_date 不能用呢 是要换别的函数?
我修改了函数 现在已经可以了
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询