To add up, here are the Create and Insert statements, to get data sample for the query above
Create the following tables
CREATE TABLE [dbo].[AAG00400](
[aaTrxDimID] [int] NULL,
[aaTrxDim] [nvarchar](max) NULL
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
GO
CREATE TABLE [dbo].[AAG00401](
[aaTrxDimID] [int] NULL,
[aaTrxDimCode] [nvarchar](max) NULL
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
GO
Then, insert the following values
INSERT INTO dbo.AAG00400
( aaTrxDimID ,aaTrxDim )
VALUES ( 1, 'Cost Center' ), (2, 'Location') , (3,'Sector')
INSERT INTO AAG00401
( aaTrxDimID, aaTrxDimCode )
VALUES ( 1, 'Administration' ),
( 1, 'Sales' ),
( 1, 'Marketing' ),
( 2, 'Export' ),
( 2, 'Local' ),
( 3, 'B2B' ),
( 3, 'B2C' )
Now, you can run the query above and check the sample data.
Your reply is highly appreciated,