use mlk;
GO
SET NUMERIC_ROUNDABORT OFF;
SET ANSI_PADDING, ANSI_WARNINGS, CONCAT_NULL_YIELDS_NULL, ARITHABORT,
QUOTED_IDENTIFIER, ANSI_NULLS ON;
GO
IF OBJECT_ID ('dbo.mt1', 'view') IS NOT NULL
DROP VIEW dbo.mt1;
GO
CREATE VIEW dbo.mt1
WITH SCHEMABINDING AS
SELECT
COUNT_BIG(*) AS counts,
//大概错误是在这里
SUM(dbo.TT_MT_LOG.MT_NOREPORT+dbo.TT_MT_LOG.MT_SUCCESS) sums,
dbo.TT_MT_LOG.APP_PARAMETER1 AS BizCode,
CONVERT(datetime,CONVERT (CHAR(10),dbo.TT_MT_LOG.SEND_TIME,120),120) AS Days
FROM
dbo.TT_MT_LOG
GROUP BY
dbo.TT_MT_LOG.APP_PARAMETER1,
CONVERT(datetime,CONVERT (CHAR(10),dbo.TT_MT_LOG.SEND_TIME,120),120)
GO
CREATE UNIQUE CLUSTERED INDEX mt_1 ON mlk.dbo.mt1(days DESC,BizCode);
GO
错误信息:
[SQL]
CREATE UNIQUE CLUSTERED INDEX mt_1 ON mlk.dbo.mt1(days DESC,BizCode)
[Err] 42000 - [SQL Server]Cannot create the clustered index "mt_1" on view "mlk.dbo.mt1" because the view references an unknown value (SUM aggregate of nullable expression). Consider referencing only non-nullable values in SUM. ISNULL() may be useful for this.
求大神们指点。