I’m trying to do something similar. I’m trying to retrieve the dimension descriptions for a journal. I am building a view and since Dynamics doesn’t support subselects I am trying to create computed columns to bring back the values that would normally be subselected. The SQL looks like this but not sure how to code the subselects as computed columns.
Select
year(ledg.transdate) Fiscal_Year,
month(ledg.transdate) Accounting_Period,
(Select acct.name
From mainaccount acct,
dimensionattributelevelvalue dalv
Where dalv.dimensionattributevaluegroup = davg.recid
And acct.MainAccountID = dalv.displayvalue
And dalv.ordinal = 1) AccountName,
(Select dpty.name
From omoperatingunit oper,
dirpartytable dpty,
dimensionattributelevelvalue dalv
Where dalv.dimensionattributevaluegroup = davg.recid
And dalv.ordinal =2
And oper.omoperatingunitnumber = dalv.displayvalue
And oper.omoperatingunittype =1
And dpty.recid = oper.recid) DeptName
From
ledgerjournaltrans ledg
CROSS JOINdimensionattributevaluegroupcombination dvgc
CROSS JOINdimensionattributevaluegroup davg
WHERE dvgc.dimensionattributevaluecombination = ledg.ledgerdimension
And davg.recid = dvgc.dimensionattributevaluegroup
And Not (Select acct.mainaccountid
From mainaccount acct,dimensionattributelevelvalue dalv
Where dalv.dimensionattributevaluegroup = davg.recid
And acct.MainAccountID = dalv.displayvalue
And dalv.ordinal = 1) is null