select * from
(
select
GENERALJOURNALENTRY.ACCOUNTINGDATE fecha,--fecha
MAINACCOUNT.MAINACCOUNTID CuentaContable,--cuenta contable
GeneralJournalAccountEntry.REPORTINGCURRENCYAMOUNT importe,--importe
DimensionAttributeLevelValue.DISPLAYVALUE dv,
DimensionAttribute.NAME Nombre,
GeneralJournalAccountEntry.RECID reciddelatransaccion
from GENERALJOURNALENTRY
inner join GeneralJournalAccountEntry on GENERALJOURNALENTRY.RECID=GeneralJournalAccountEntry.GENERALJOURNALENTRY
inner join DIMENSIONATTRIBUTEVALUECOMBINATION on GeneralJournalAccountEntry.LEDGERDIMENSION=DIMENSIONATTRIBUTEVALUECOMBINATION.RECID
inner join MAINACCOUNT on DIMENSIONATTRIBUTEVALUECOMBINATION.MAINACCOUNT=MAINACCOUNT.RECID
--inner join ABXEBITDADATOSSOBRESALIENTE on MAINACCOUNT.MAINACCOUNTID=ABXEBITDADATOSSOBRESALIENTE.CUENTACONTABLE
inner join DimensionAttributeValueGroupCombination on DIMENSIONATTRIBUTEVALUECOMBINATION.RECID=DimensionAttributeValueGroupCombination.DIMENSIONATTRIBUTEVALUECOMBINATION
inner join DimensionAttributeValueGroup on DimensionAttributeValueGroupCombination.DIMENSIONATTRIBUTEVALUEGROUP=DimensionAttributeValueGroup.RECID
inner join DimensionAttributeLevelValue on DimensionAttributeValueGroup.RECID=DimensionAttributeLevelValue.DIMENSIONATTRIBUTEVALUEGROUP
inner join DimensionAttributeValue on DimensionAttributeValue.RECID=DimensionAttributeLevelValue.DIMENSIONATTRIBUTEVALUE
inner join DimensionAttribute on DimensionAttribute.RECID=DimensionAttributeValue.DIMENSIONATTRIBUTE
--where ABXEBITDADATOSSOBRESALIENTE.CONCEPTO in (2,3,4,5)
)p
pivot (max(dv) for Nombre in ([MainAccount],[División],[Sucursal])) piv -- **
No hay comentarios:
Publicar un comentario