所以我有一种情况,我知道该过程将查询以UTCStampTime方式格式化的行。我遇到的问题是当我想在两个CTE上建立一个查询时,我只需要在每个CTE变量的时间相等时返回。但问题是我的查询仅查看最后10分钟,并且我只希望当utcTimeStamp列的分钟相同时两行相等。这是我正在运行的查询。
GO
declare @fqnLine1Downtime varChar(4000)
declare @fqnLine1Throughput varChar(400)
declare @fqnLine2Downtime varChar(4000)
declare @fqnLine2Throughput varChar(400)
declare @parameter1Line1 varChar(4000)
declare @parameter2Line1 varChar(4000)
declare @parameter1Line2 varChar(4000)
declare @parameter2Line2 varChar(4000)
declare @server varChar(200)
declare @timeStart datetime
declare @timeEnd datetime
WITH
CTEThroughputLine1(Time, Amount, ThroughputLine1)
AS
--Define the query
(
SELECT CONVERT(VarChar(20),utcTimeStamp) as Time, shortName as
ThroughputLine1, valueAsInt as Amount
From dbo.History(@fqnLine1Throughput, @parameter2Line1, @timeStart,
@timeEnd, @server)
),
CTEThroughputLine2(ThroughputLine2, Amount, Time)
AS
(
Select shortName as ThroughputLine2, valueAsFloat as Amount,
CONVERT(VarChar(20),utcTimeStamp) as Time
From dbo.History(@fqnLine2Throughput, @parameter2Line2, @timeStart,
@timeEnd, @server)
)
select * from CTEThroughputLine1 as Line1 inner join
CTEThroughputLine2 as Line2 on Line1.Time = Line2.Time
我故意不包含变量的设置,因为它包含我公司的私人信息。我认为这应该足以解决这个问题。请帮忙或指出提示。