I'm trying to use subselects to return the dimension name values in one row. Since the dimension values are segregated by the ordinal value in teh dimensionattributelevelvalue table I need to subselect from there. How do I build a query or view in the AOT to do this. My SQL looks like this. Your above answer seems to suggest you don't think subselects are ever necessary. If you don;t use subselects to get these values then how would you do it?
Select year(ledg.transdate) Fiscal_Year,
month(ledg.transdate) Accounting_Period,
(Select acct.mainaccountid
From mainaccount acct,
dimensionattributelevelvalue dalv
Where dalv.dimensionattributevaluegroup = davg.recid
And acct.MainAccountID = dalv.displayvalue
And dalv.ordinal = 1) AccountID,
(Select acct.name
From mainaccount acct,
dimensionattributelevelvalue dalv
Where dalv.dimensionattributevaluegroup = davg.recid
And acct.MainAccountID = dalv.displayvalue
And dalv.ordinal = 1) AccountName,
(Select oper.omoperatingunitnumber
From omoperatingunit oper,
dimensionattributelevelvalue dalv
Where dalv.dimensionattributevaluegroup = davg.recid
And dalv.ordinal = 2
And oper.omoperatingunitnumber = dalv.displayvalue
And oper.omoperatingunittype = 1) DeptID,
(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,
(Select dmft.Description
From dimensionfinancialtag dmft,
dimensionattributelevelvalue dalv
Where dalv.dimensionattributevaluegroup = davg.recid
And dalv.ordinal = 3
And dmft.value = dalv.displayvalue
And dmft.FinancialTagCategory = 5637144577) Product,
(Select dmft.Description
From dimensionfinancialtag dmft,
dimensionattributelevelvalue dalv
Where dalv.dimensionattributevaluegroup = davg.recid
And dalv.ordinal = 4
And dmft.value = dalv.displayvalue
And dmft.FinancialTagCategory = 5637144576) Project,
amountcurcredit credit_amount,
amountcurdebit debit_amount
From ledgerjournaltrans ledg
CROSS JOIN dimensionattributevaluegroupcombination dvgc
CROSS JOIN dimensionattributevaluegroup 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
Union
Select year(ledg.transdate) Fiscal_Year,
month(ledg.transdate) Accounting_Period,
(Select acct.mainaccountid
From mainaccount acct,
dimensionattributelevelvalue dalv
Where dalv.dimensionattributevaluegroup = davg.recid
And acct.MainAccountID = dalv.displayvalue
And dalv.ordinal = 1) AccountID,
(Select acct.name
From mainaccount acct,
dimensionattributelevelvalue dalv
Where dalv.dimensionattributevaluegroup = davg.recid
And acct.MainAccountID = dalv.displayvalue
And dalv.ordinal = 1) AccountName,
(Select oper.omoperatingunitnumber
From omoperatingunit oper,
dimensionattributelevelvalue dalv
Where dalv.dimensionattributevaluegroup = davg.recid
And dalv.ordinal = 2
And oper.omoperatingunitnumber = dalv.displayvalueOM
And oper.omoperatingunittype = 1) DeptID,
(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,
(Select dmft.Description
From dimensionfinancialtag dmft,
dimensionattributelevelvalue dalv
Where dalv.dimensionattributevaluegroup = davg.recid
And dalv.ordinal = 3
And dmft.value = dalv.displayvalue
And dmft.FinancialTagCategory = 5637144577) Product,
(Select dmft.Description
From dimensionfinancialtag dmft,
dimensionattributelevelvalue dalv
Where dalv.dimensionattributevaluegroup = davg.recid
And dalv.ordinal = 4
And dmft.value = dalv.displayvalue
And dmft.FinancialTagCategory = 5637144576) Project,
amountcurcredit credit_amount,
amountcurdebit debit_amount
From ledgerjournaltrans ledg
CROSS JOIN dimensionattributevaluegroupcombination dvgc
CROSS JOIN dimensionattributevaluegroup davg
WHERE dvgc.dimensionattributevaluecombination = ledg.offsetledgerdimension
And davg.recid = dvgc.dimensionattributevaluegroup
And (Select acct.mainaccountid
From mainaccount acct,
dimensionattributelevelvalue dalv,
dimensionattributevaluegroup davg2,
dimensionattributevaluegroupcombination davc2
Where davc2.dimensionattributevaluecombination = ledg.ledgerdimension
And davg2.recid = davc2.dimensionattributevaluegroup
And dalv.dimensionattributevaluegroup = davg2.recid
And acct.MainAccountID = dalv.displayvalue
And dalv.ordinal = 1) is null