我有(我认为是)一个相对复杂的SQL查询来为我在工作中维护的一个应用程序的新功能选择一些数据。下面是查询。
SELECT pchtq.[sourceappid],
pchtq.[transactioncode],
pchtq.[accountid],
pchtq.[year],
pchtq.[filingdatetime],
pchtq.[amount],
pchtq.[note],
pchtq.Status,
pchtq.SourceRecordID,
utaq.fullname,
utaq.username
FROM [database].[dbo].[transactions1] pchtq
INNER JOIN [database].[dbo].[useraccounts] utaq
ON pchtq.[accountid] = utaq.[accountid]
WHERE
pchtq.status = 'failed'
AND pchtq.[recordcreatedatetime] >= '01/01/2015'
AND pchtq.[recordcreatedatetime] <= '05/11/2016'
and Not exists
(
select TransactionID
from
Database.dbo.Transactions2 eft
where
CAST(eft.TransactionID as nvarchar(50)) = pchtq.SourceRecordID
and eft.status IN( 'paid', 'audit' )
)在实体空间中,我把它写成这样:
pchtq
.Select(
pchtq.SourceAppID,
pchtq.TransactionCode,
pchtq.AccountID,
pchtq.Year,
pchtq.FilingDateTime,
pchtq.Amount,
pchtq.Note
).InnerJoin(utaq).On(pchtq.AccountID == utaq.AccountID)
.Where(pchtq.RecordCreateDateTime >= request.StartDate
&& pchtq.RecordCreateDateTime <= request.EndDate
&& pchtq.Status == "FAILED")
.NotExists(
eftq.Select(
eftq.EFileTransactionID
).Where(eftq.Status.In("Paid", "Audit")
&& Convert.ToString(eftq.TransactionID) == pchtq.SourceRecordID));然而,当我在ES应用程序中运行它(使用pchtc.Load(pchtq))时,我得到了大约7500行,而当我运行SQL查询时,我得到了大约1500行。
这里出了什么问题?
发布于 2016-05-12 01:09:50
也许是因为你的字符串大小写不同?“失败”vs“失败”和“审计”vs“审计”?
老实说,这是我能看到的唯一区别。
https://stackoverflow.com/questions/37167975
复制相似问题