Select 同时区分和排序
Select Distinct and sequence at the same time
如何在 select 语句上使用 Distinct
以及 SQL Server
上的序列
我尝试了这个子查询,但运气不好,我得到了
的错误
NEXT VALUE FOR function is not allowed in check constraints, default objects, computed columns, views, user-defined functions, user-defined aggregates, user-defined table types, sub-queries, common table expressions, derived tables or return statements.
Select Distinct (Select
Next Value for dbo.P_PM_TBlIF240_SEQ , 'PH70', LEFT(ToolID, LEN(ToolID) - 2) as TOOLID, UsedLife, GETDATE(), CURRENT_TIMESTAMP, 'PH70-TA'
From
Machine_ToolItem_Relationship ) from Machine_ToolItem_Relationship
谁能帮我解决这个问题?
解决谢谢@Nick.McDermaid我的最终查询是这样的。
Select
Next Value for dbo.P_PM_TBlIF240_SEQ , 'PH70', LEFT(ToolID, LEN(a.ToolID) - 2) as TOOLID, a.UsedLife, GETDATE(), CURRENT_TIMESTAMP, 'PH70-TA'
from (Select
Distinct LEFT(ToolID, LEN(ToolID) - 2) as TOOLID, UsedLife
from Machine_ToolItem_Relationship) as a
如何在 select 语句上使用 Distinct
以及 SQL Server
我尝试了这个子查询,但运气不好,我得到了
的错误NEXT VALUE FOR function is not allowed in check constraints, default objects, computed columns, views, user-defined functions, user-defined aggregates, user-defined table types, sub-queries, common table expressions, derived tables or return statements.
Select Distinct (Select
Next Value for dbo.P_PM_TBlIF240_SEQ , 'PH70', LEFT(ToolID, LEN(ToolID) - 2) as TOOLID, UsedLife, GETDATE(), CURRENT_TIMESTAMP, 'PH70-TA'
From
Machine_ToolItem_Relationship ) from Machine_ToolItem_Relationship
谁能帮我解决这个问题?
解决谢谢@Nick.McDermaid我的最终查询是这样的。
Select
Next Value for dbo.P_PM_TBlIF240_SEQ , 'PH70', LEFT(ToolID, LEN(a.ToolID) - 2) as TOOLID, a.UsedLife, GETDATE(), CURRENT_TIMESTAMP, 'PH70-TA'
from (Select
Distinct LEFT(ToolID, LEN(ToolID) - 2) as TOOLID, UsedLife
from Machine_ToolItem_Relationship) as a