试图修改现有视图。它目前在我的数据库中返回 32 行。这是代码:
ALTER VIEW [dbo].[vw_fnd_la_Statement]
AS
SELECT
SH.lease_id, S.expense_id, SH.statement_header_id, S.statement_id AS row_id,
EC.name AS expense_category, SH.period, S.invoice_number,
S.received_date, S.due_date, S.landlord_expense_total, S.prorata_share,
S.tenant_expense_total, S.tenant_admin_fee, S.paid_estimates, S.net_due,
CASE
WHEN s.status = 'O' THEN 'Open'
WHEN s.status = 'P' THEN 'In Progress'
WHEN s.status = 'D' THEN 'In Dispute'
WHEN s.status = 'C' THEN 'Closed'
ELSE NULL
END AS status, S.approval,
dbo.UDF_getExpenseVendor(S.expense_id) AS vendor, S.approved_amount,
S.approved_payment_amount, S.disputed_amount, S.held_amount, S.statement_id,
EC.expense_category_id, SH.start_date, SH.end_date, S.status AS status_id
FROM
la_tbl_statement_header AS SH
INNER JOIN
la_tbl_statement AS S ON SH.statement_header_id = S.statement_header_id
INNER JOIN
la_tlu_expense_category AS EC ON S.expense_category_id = EC.expense_category_id
WHERE
(SH.IsDeleted = 0) AND (S.IsDeleted = 0) AND (EC.IsDeleted = 0)
我有第四个表la_tbl_expense_cap_setup
,它有一个生效日期列和一个与表中的费用 ID 匹配的费用 ID la_tbl_statement
。我想要的是现有视图的所有结果,加上一个带有生效日期的新列。有些费用没有上限,因此该行在生效日期列中应为 NULL。我已经尝试加入费用 ID,但我得到了 19 行的子集。