我有一个名为“IncomeRecievedGeneralNeeds”的主数据集。这是主报告中使用的内容。这包括一个名为“Scheme”的字段
我创建了一个名为“scheme”的新数据集和一个名为scheme的参数,但我只希望scheme参数显示主数据集中的方案。目前它显示的是不在主数据集中的方案
Scheme代码在这里 -
SELECT DISTINCT loc.scheme AS 'Scheme'
FROM ih_location loc
IncomeRecievedGeneralNeeds代码在这里 -
SELECT DISTINCT trans.tncy_sys_ref AS 'TncySysRef'
,ten.tenancy_ref AS 'TenancyRef'
,trans.created_date AS 'TransactionCreatedDate'
,MHS.startdate AS 'StartofWeekDate'
,MHS.enddate AS 'EndofWeekDate'
,MHS.financialyear AS 'TransactionFiscalYear'
,MHS.monthname AS 'TransactionFiscalMonthName'
,MHS.month AS 'TransactionFiscalMonth'
,MHS.week AS 'TransactionFiscalWeek'
,CONCAT('Week ',
MHS.week,
' (',
CONVERT(varchar(11),MHS.startdate,103),
'-',
CONVERT(varchar(11),MHS.enddate,103),
')'
) AS 'TransactionFiscalWeekWithDates'
,trans.comment_ AS 'TransactionComment'
,trans.trans_amt AS 'TransactionAmount'
,CASE WHEN trans.account_type IN ('IN','LI') Then 'Income'
WHEN trans.account_type = 'HB' Then 'HousingBenefit'
ELSE '' END AS 'AccountType'
,trans.account_type
,ACC.description AS 'AccountCode'
,loc.scheme AS 'Scheme'
,loc.mgt_area AS 'Management Area'
,loc.location_type AS 'Location Type'
,loct.description AS 'Location Type Description'
,ten.tncy_start AS 'TenancyStartDate'
,ten.tncy_end AS 'TenancyEndDate'
,CASE WHEN ten.tncy_end IS NULL
OR TRANS.created_date < ten.tncy_end
THEN 'Current' ELSE 'Former' END AS 'IncomeTenancyStatus'
,ten.tncy_status AS 'TenanacyStatus'
,CASE WHEN ten.tncy_status = 'FOR' THEN LOC.former_arrs_ofcr ELSE loc.arrears_ofcr END AS 'OfficerCode'
FROM [dbo].[re_tncy_trans] trans
INNER JOIN
re_tenancy ten
ON trans.tncy_sys_ref = ten.tncy_sys_ref
INNER JOIN
re_tncy_place tenpl
ON TEN.tncy_sys_ref = tenpl.tncy_sys_ref
INNER JOIN
ih_location loc
ON tenpl.place_ref = loc.place_ref
INNER JOIN
[dbo].[re_accounts] acc
ON
trans.account_code = ACC.account_code
AND trans.account_type = acc.account_type
INNER JOIN
[mhsInsight].[dbo].[mhs_month_week] mhs
ON trans.created_date BETWEEN mhs.startdate AND MHS.enddate
INNER JOIN
[dbo].[ih_location_type] AS loct
ON loc.location_type = LOCT.location_type
WHERE trans.account_type IN ('IN','HB','LI')
AND MHS.startdate >= CONVERT(DATETIME, '2014-04-07 00:00:00', 102)
and loc.place_ref <> '9999999999'
答案 0 :(得分:0)
在参数查询中,使用您在主查询中使用的相同FROM和WHERE子句,并且只获得与主数据集中相同的Schemes。