1つまたは2つのビューに配置する必要のある、個別の小さな選択クエリがたくさんあります。これらのクエリは、最終的に結合され、提案が必要になります。ストアドプロシージャでうまく機能しないサードパーティのアドホックアプリケーションを使用しているため、一時テーブルは適切ではありません。これをどのように達成できるかについて誰かが何か提案がありますか?以下はクエリです:
select count(cmrckid)as TotalRDIs
FROM tblCMRCK
select count(AccountID)as TotalMerchants
FROM tblAccounts
select count(AccountID)as TotalActiveMerchants
FROM tblAccounts
where inactive = 0
select count(AccountID)as TotalInActiveMerchants
FROM tblAccounts
where inactive = 1
select count(AccountID)as TotalwithRDIs
FROM [tblAccounts] a WITH (NOLOCK) inner join
[tblcmrck] c WITH (NOLOCK) on a.configid=c.configid and a.accountid=c.acctid
select COUNT(AccountID) as ActivewithRDIs
FROM [tblAccounts] a WITH (NOLOCK) inner join
[tblcmrck] c WITH (NOLOCK) on a.configid=c.configid and a.accountid=c.acctid
where a.Inactive = 0
select COUNT(AccountID) as ActivewithoutRDIs
FROM [tblAccounts] a WITH (NOLOCK)
where a.inactive = 0 and a.AccountID not in (select AcctID from tblCMRCK)
--select 'Total Active Merchants' / 'Total Merchants' as 'PctActive'
--from #tmptable
--select 'Total InActive Merchants' / 'Total Merchants' as 'PctInActive'
--from #tmpTableExample2
--select 'Active with RDIs' / 'Total Merchants' as 'PctActivewithRDIs'
--FROM #tmpTableExample
--select 'Active without RDIs' / 'Total Merchants' as 'PctActivewithoutRDIs'
--FROM #tmpTableExample