我创建了一个连接到来自两个不同数据库的两个表的视图
我正在尝试:
将下面的两列从 int
转换为 decimal
,精度为 4
[Talk_Count] + [Alloc_Count] AS [Talk]
[CT_Count] - [NP_Count] / [CT_Count] AS [Quality]
对数据进行排序
WHERE [Call_Date] <= 13
我该怎么做,下面是我的视图结构
SELECT
Call_DT,
Talk_Sec_Count + Alloc_Sec_Count AS Talk,
CT_Count - NP_Count / CT_Count AS Quality,
Pymt_Rtn_Rt AS Utilization,
Agent_UID
FROM
[TableName]
答案 0 :(得分:2)
WHERE
不用于排序......并且您不能在视图定义内排序 - 您可以在 {{1} 时排序(通过使用显式 ORDER BY
) } 从那个角度来看。
你可以尝试这样的事情:
SELECT
然后您可以从该视图中 CREATE VIEW dbo.YourViewNameHere
AS
SELECT
Call_DT,
CAST(Talk_Sec_Count + Alloc_Sec_Count AS DECIMAL(16, 4)) AS Talk,
CAST(CT_Count * 1.0 - NP_Count / CT_Count * 1.0 AS DECIMAL(16, 4)) AS Quality,
Pymt_Rtn_Rt AS Utilization,
Agent_UID
FROM
[TableName]
WHERE
[Call_Date] <= 13 -- not clear if that's really your condition.... adapt as needed
并添加您的 SELECT
:
ORDER BY