Grossmargin by item report adding mainaccount

I am creating the grossmargin by item report in ssrs. It will be the same report available in AX but will be add the mainaccountid(mainaccount in GL) as a column. i am able to replicate the query using CustGrossMarginbyItem_NA. Now i need to add a column mainaccountid to this report but I do not know how to join the tables in my dataset to mainaccount table in the query. Please help.