T-SQL:提取子集



我在问题本上有一个问题,但是我卡住了:

Q:数据库PaymentLoad中的表DebtPayment_DL需要一个信息提取的子集来显示DebtAccountReferences,01/01/2021之后有一个PaymentStartDate,没有截止日期。

模式:

[DebtAccountReferences] - varchar(50) not null
[PaymentStartDate] - datetime, not null
[CloseDate] - Datetime, not null

我的尝试:

SELECT * 
FROM DebtPayment_DL 
WHERE PaymentStartDate > 01/01/2021 AND CloseDate IS NULL

现在我还需要一个连接语句来连接表DebtPayment_DLDebtAccountReferences吗?如果这是错误的,请纠正我。

我不太确定结果是什么,我不认为有一个具体的结果,只是一个生动的想法。

不应该有任何连接,因为信息在该表中是可用的。您可以根据需要只选择debtaccountreference,而不是选择所有列。

select DebtAccountReferences
from DebtPayment_DL 
where PaymentStartDate > '01/01/2021' and CloseDate is null;

根据您提供的信息,您不需要连接语句。您需要的所有信息都存储在表'DebtPayment_DL'

中因此你的代码是正确的,并且应该生成正确的输出。

最新更新