SSIS package 排序不成功
0
SSIS package coding如下:
SELECT
YEAR(AL1.GMTCreatedDateTime) as Open_Year,
Month(AL1.GMTCreatedDateTime) as Open_Month,
CONVERT(varchar(100),dateadd(dd,-datepart(weekday,AL1.GMTCreatedDateTime)+8,AL1.GMTCreatedDateTime), 101) as Week_Number,
AL1.ServiceRequestId,
AL1.GMTCreatedDateTime,
AL1.GMTFirstAgentMsgDateTime,
AL1.GMTFirstAssignedDateTime,
AL1.GMTClosedDateTime,
AL1.ResolutionCode,
datepart(HOUR,AL1.GMTCreatedDateTime) as Hour_Created,
AL1.SecondsUntilFirstAgentMsg,
CONVERT(varchar(100),AL1.GMTCreatedDateTime, 101) as Create_DAY,
cast(round(AL1.SecondsUntilFirstAgentMsg*1.0/60,2) as numeric(9,2)) as Reply_Times_Final,
case when AL1.SecondsUntilFirstAgentMsg>120 then '0'
else '1' end as SL_met_miss,
AL2.QueueName as CurrentQueueName,
AL3.QueueName as InitialQueueName,
case when AL2.QueueName=AL3.QueueName then '0'
else '1' end as Misroute,
AL1.WorkTimeSeconds,
case when AL1.GMTFirstAgentMsgDateTime IS null then '1'
else '0' end as Abandoned,
AL6.Countryname,
AL1.IsUnderWarranty,
AL1.ExternalRefKey,
AL1.RemoteControlUsedCount,
AL1.RemoteControlTimeInSeconds,
AL1.SRCreateMethod,
AL1.ProductNo,
upper(AL1.SerialNo) as SerialNumber,
AL1.EntitlementStatus,
1 as Event_Count,
ROW_NUMBER() over(partition by AL1.ExternalRefKey order by AL1.ExternalRefKey) as Case_Event_Count,
AL4.Gmtcurrenteventdate,
AL4.Gmtnexteventdate,
DATEDIFF(s,AL4.Gmtcurrenteventdate,AL4.Gmtnexteventdate) as Event_Time_Sec,
AL5.[FirstName]+'_'+AL5.[LastName] as Event_Agent
FROM
[dbo].[SRFact] AL1 left join [dbo].[Countrydim] AL6 on AL1.Countrydimid=AL6.Countrydimid
left join [dbo].[QueueDim] AL3 on AL1.InitialQueueDimId=AL3.QueueDimId
left join [dbo].[QueueDim] AL2 on AL1.CurrentQueueDimId=AL2.QueueDimId
full join [dbo].[Srassignmenthistory] AL4 on AL1.ServiceRequestId=AL4.ServiceRequestId
join [dbo].[AgentDim] AL5 on AL4.AgentDimId=AL5.AgentDimID
where (AL1.GMTCreatedDateTime>=DATEADD(d,-60,getdate()))
and (AL3.QueueName in (
**数百条queue list**
))
order by AL1.ServiceRequestId, AL4.Gmtcurrenteventdate
需要达到的目的是数据以ServiceRequestId,Gmtcurrenteventdate的优先次序排序,但目的没有达到。在写入表中的4万多条数据好像分成很多段,每段内的数据是按照要求排序的,但段与段之间没有。
后来希望通过 sort 功能排序,但也没有成功。
附上截图,
显示数据未正确排序。
显示 sort功能的设置。
请教各位如何解决?多谢!
SELECT
YEAR(AL1.GMTCreatedDateTime) as Open_Year,
Month(AL1.GMTCreatedDateTime) as Open_Month,
CONVERT(varchar(100),dateadd(dd,-datepart(weekday,AL1.GMTCreatedDateTime)+8,AL1.GMTCreatedDateTime), 101) as Week_Number,
AL1.ServiceRequestId,
AL1.GMTCreatedDateTime,
AL1.GMTFirstAgentMsgDateTime,
AL1.GMTFirstAssignedDateTime,
AL1.GMTClosedDateTime,
AL1.ResolutionCode,
datepart(HOUR,AL1.GMTCreatedDateTime) as Hour_Created,
AL1.SecondsUntilFirstAgentMsg,
CONVERT(varchar(100),AL1.GMTCreatedDateTime, 101) as Create_DAY,
cast(round(AL1.SecondsUntilFirstAgentMsg*1.0/60,2) as numeric(9,2)) as Reply_Times_Final,
case when AL1.SecondsUntilFirstAgentMsg>120 then '0'
else '1' end as SL_met_miss,
AL2.QueueName as CurrentQueueName,
AL3.QueueName as InitialQueueName,
case when AL2.QueueName=AL3.QueueName then '0'
else '1' end as Misroute,
AL1.WorkTimeSeconds,
case when AL1.GMTFirstAgentMsgDateTime IS null then '1'
else '0' end as Abandoned,
AL6.Countryname,
AL1.IsUnderWarranty,
AL1.ExternalRefKey,
AL1.RemoteControlUsedCount,
AL1.RemoteControlTimeInSeconds,
AL1.SRCreateMethod,
AL1.ProductNo,
upper(AL1.SerialNo) as SerialNumber,
AL1.EntitlementStatus,
1 as Event_Count,
ROW_NUMBER() over(partition by AL1.ExternalRefKey order by AL1.ExternalRefKey) as Case_Event_Count,
AL4.Gmtcurrenteventdate,
AL4.Gmtnexteventdate,
DATEDIFF(s,AL4.Gmtcurrenteventdate,AL4.Gmtnexteventdate) as Event_Time_Sec,
AL5.[FirstName]+'_'+AL5.[LastName] as Event_Agent
FROM
[dbo].[SRFact] AL1 left join [dbo].[Countrydim] AL6 on AL1.Countrydimid=AL6.Countrydimid
left join [dbo].[QueueDim] AL3 on AL1.InitialQueueDimId=AL3.QueueDimId
left join [dbo].[QueueDim] AL2 on AL1.CurrentQueueDimId=AL2.QueueDimId
full join [dbo].[Srassignmenthistory] AL4 on AL1.ServiceRequestId=AL4.ServiceRequestId
join [dbo].[AgentDim] AL5 on AL4.AgentDimId=AL5.AgentDimID
where (AL1.GMTCreatedDateTime>=DATEADD(d,-60,getdate()))
and (AL3.QueueName in (
**数百条queue list**
))
order by AL1.ServiceRequestId, AL4.Gmtcurrenteventdate
需要达到的目的是数据以ServiceRequestId,Gmtcurrenteventdate的优先次序排序,但目的没有达到。在写入表中的4万多条数据好像分成很多段,每段内的数据是按照要求排序的,但段与段之间没有。
后来希望通过 sort 功能排序,但也没有成功。
附上截图,
显示数据未正确排序。
显示 sort功能的设置。
请教各位如何解决?多谢!
没有找到相关结果
重要提示:提问者不能发表回复,可以通过评论与回答者沟通,沟通后可以通过编辑功能完善问题描述,以便后续其他人能够更容易理解问题.
2 个回复
BIWORK - 热衷于微软BI技术,技术架构和解决方案! 2015-10-22 回答
赞同来自:
目标表的数据顺序无所谓,下次查询使用的时候排序一下就可以了,完全不用考虑这些顺序的问题。 因为在 SSIS 里面不像事务处理系统的数据是一条一条处理,一定是和操作时间顺序一致,SSIS 中这几个控件不是这样的。
你可以试着把 OLE DB Destination 中的 Bulk Insert 改成普通的 Insert 看看有没有区别。
其实输出结果在目标表里排序不排序我看来没有什么区别,不用考虑这个问题了。
天桥下的郑成功 - Hadoop大数据开发工程师、数仓架构师、熟悉数据仓库设计、Hadoop、Spark、HBase、Hive、SSIS等开发 2015-10-22 回答
赞同来自:
在Lookup后, 为何还要再次排序