我的sql server中有这条记录..
RecId RefJobTicket TimeStart TimeEnd VerByStart VerByEnd Cargo PreTrip Transit LoadingUnloading WaitForAdvice MealBreak Breakdown PostTrip Refuel Remarks 2 1 12:00 1:00 NULL NULL NULL 0 0 0 0 0 0 NULL 0 NULL 49 1 3:00 4:00 NULL NULL NULL 0 0 0 0 0 0 NULL 0 NULL 50 1 5:00 8:00 NULL NULL NULL 0 0 0 0 0 0 NULL 0 NULL
在我的SSRS报告中..我想根据我在sql server中的可用记录将它放在一个预定义的表单中,如下所示:
time start time end Refuel Trip Meal Break
12:01AM 1:00AM 0 Null Null 1:01AM 2:00AM 2:01AM 3:00AM 3:01AM 4:00AM Null 0 Null 4:01AM 5:00AM 5:01AM 6:00AM Null Null 0 6:01AM 7:00AM Null Null 0 7:01AM 8:00AM Null Null 0
8:01AM 9:00AM 9:01AM 10:00AM 10:01AM 11:00AM 11:01AM 12:00PM 12:01PM 1:00PM 1:01PM 2:00PM 2:01PM 3:00PM 3:01PM 4:00PM 4:01PM 5:00PM 5:01PM 6:00PM 6:01PM 7:00PM 7:01PM 8:00PM 8:01PM 9:00PM 9:01PM 10:00PM 10:01PM 11:00PM 11:01PM 12:00AM
我可以在ssrs r2中这样做吗?任何人都可以帮助我吗?
答案 0 :(得分:1)
是的,你可以做到。你需要注意以下几点:
<强>步骤1:强> 您的查询应始终返回(上午12:01至凌晨12:00)。您可以在主查询上进行以下查询的交叉连接。请注意,报告无法生成那些不是来自SQL查询的时间。
;with Minute_Cycle
as
(
select cast('12:01AM' as time) Mint
Union ALL
Select DATEADD(HOUR,1,cast(Mint as time)) Mint from Minute_Cycle
where convert(varchar(15),cast(Mint as time),100)<>'11:01PM'
)
Select convert(varchar(15),Mint,100) as time_start, convert(varchar(15),DATEADD(MINUTE,59,Mint),100) time_End from Minute_Cycle
<强>第二步强> 放置一张桌子并根据您的选择设计您的报告。