SELECT RTRIM(['RM Customer MSTR'].CUSTNMBR) AS [Customer Number], RTRIM(['RM Customer MSTR'].CUSTNAME) AS [Customer Name], RTRIM(['RM Customer MSTR'].ADDRESS1) AS [Address 1], RTRIM(['RM Customer MSTR'].ADDRESS2) AS [Address 2], RTRIM(['RM Customer MSTR'].CITY) AS City, RTRIM(['RM Customer MSTR'].STATE) AS State, RTRIM(['RM Customer MSTR'].ZIP) AS Zip, RTRIM(['RM Customer MSTR'].PHONE1) AS [Phone 1], ['Customer Master Summary'].AGPERAMT_1 AS [Aging Bucket1], ['Customer Master Summary'].AGPERAMT_2 AS [Aging Bucket2], ['Customer Master Summary'].AGPERAMT_3 AS [Aging Bucket3], ['Customer Master Summary'].AGPERAMT_4 AS [Aging Bucket4], ['Customer Master Summary'].AGPERAMT_5 AS [Aging Bucket5], ['Customer Master Summary'].AGPERAMT_6 AS [Aging Bucket6], ['Customer Master Summary'].AGPERAMT_7 AS [Aging Bucket7], (SELECT RTRIM(ACTNUMST) AS Expr1 FROM dbo.GL00105 AS ['Account Index Master'] WHERE (ACTINDX = ['RM Customer MSTR'].RMARACC)) AS [Accounts Receivable Account Number], RTRIM(['RM Customer MSTR'].ADDRESS3) AS [Address 3], RTRIM(['RM Customer MSTR'].ADRSCODE) AS [Address Code], ['Customer Master Summary'].AVDTPLIF AS [Average Days To Pay - Life], ['Customer Master Summary'].AVGDTPYR AS [Average Days To Pay - Year], ['Customer Master Summary'].AVDTPLYR AS [Average Days to Pay - LYR], dbo.DYN_FUNC_Balance_Type(['RM Customer MSTR'].BALNCTYP) AS [Balance Type], RTRIM(['RM Customer MSTR'].BNKBRNCH) AS [Bank Branch], RTRIM(['RM Customer MSTR'].BANKNAME) AS [Bank Name], (SELECT RTRIM(ACTNUMST) AS Expr1 FROM dbo.GL00105 AS ['Account Index Master'] WHERE (ACTINDX = ['RM Customer MSTR'].RMCOSACC)) AS [COGS Account Number], (SELECT RTRIM(ACTNUMST) AS Expr1 FROM dbo.GL00105 AS ['Account Index Master'] WHERE (ACTINDX = ['RM Customer MSTR'].RMCSHACC)) AS [Cash Account Number], RTRIM(['RM Customer MSTR'].CHEKBKID) AS [Checkbook ID], RTRIM(['RM Customer MSTR'].COMMENT1) AS Comment1, RTRIM(['RM Customer MSTR'].COMMENT2) AS Comment2, RTRIM(['RM Customer MSTR'].CNTCPRSN) AS [Contact Person], RTRIM(['RM Customer MSTR'].CPRCSTNM) AS [Corporate Customer Number], RTRIM(['RM Customer MSTR'].COUNTRY) AS Country, ['RM Customer MSTR'].CREATDDT AS [Created Date], ['RM Customer MSTR'].CCRDXPDT AS [Credit Card Exp Date], RTRIM(['RM Customer MSTR'].CRCARDID) AS [Credit Card ID], ['RM Customer MSTR'].CRLMTAMT AS [Credit Limit Amount], ['RM Customer MSTR'].CRLMTPER AS [Credit Limit Period], ['RM Customer MSTR'].CRLMTPAM AS [Credit Limit Period Amount], dbo.DYN_FUNC_Credit_Limit_Type(['RM Customer MSTR'].CRLMTTYP) AS [Credit Limit Type], RTRIM(['RM Customer MSTR'].CURNCYID) AS [Currency ID], ['Customer Master Summary'].CUSTBLNC AS [Customer Balance], RTRIM(['RM Customer MSTR'].CUSTCLAS) AS [Customer Class], ['RM Customer MSTR'].CUSTDISC / 100.00 AS [Customer Discount], dbo.DYN_FUNC_Default_Cash_Account_Type(['RM Customer MSTR'].DEFCACTY) AS [Default Cash Account Type], ['Customer Master Summary'].DEPRECV AS [Deposits Received], ['RM Customer MSTR'].DISGRPER AS [Discount Grace Period], (SELECT RTRIM(ACTNUMST) AS Expr1 FROM dbo.GL00105 AS ['Account Index Master'] WHERE (ACTINDX = ['RM Customer MSTR'].RMAVACC)) AS [Discounts Available Account Number], (SELECT RTRIM(ACTNUMST) AS Expr1 FROM dbo.GL00105 AS ['Account Index Master'] WHERE (ACTINDX = ['RM Customer MSTR'].RMTAKACC)) AS [Discounts Taken Account Number], RTRIM(['RM Customer MSTR'].DOCFMTID) AS [Document Format ID], ['RM Customer MSTR'].DUEGRPER AS [Due Date Grace Period], RTRIM(['RM Customer MSTR'].FAX) AS Fax, (SELECT RTRIM(ACTNUMST) AS Expr1 FROM dbo.GL00105 AS ['Account Index Master'] WHERE (ACTINDX = ['RM Customer MSTR'].RMFCGACC)) AS [Finance Charge Account Number], dbo.DYN_FUNC_Finance_Charge_Amt_Type(['RM Customer MSTR'].FNCHATYP) AS [Finance Charge Amt Type], ['RM Customer MSTR'].FINCHDLR AS [Finance Charge Dollar], RTRIM(['RM Customer MSTR'].FINCHID) AS [Finance Charge ID], ['RM Customer MSTR'].FNCHPCNT / 100.00 AS [Finance Charge Percent], ['Customer Master Summary'].FNCHCYTD AS [Finance Charges CYTD], ['Customer Master Summary'].FNCHLYRC AS [Finance Charges LYR Calendar], ['RM Customer MSTR'].FRSTINDT AS [First Invoice Date], RTRIM(['RM Customer MSTR'].GOVCRPID) AS [Governmental Corporate ID], RTRIM(['RM Customer MSTR'].GOVINDID) AS [Governmental Individual ID], ['Customer Master Summary'].HIBALLTD AS [High Balance LTD], ['Customer Master Summary'].HIBALLYR AS [High Balance LYR], ['Customer Master Summary'].HIBALYTD AS [High Balance YTD], dbo.DYN_FUNC_Boolean_All(['RM Customer MSTR'].HOLD) AS Hold, dbo.DYN_FUNC_Boolean_All(['RM Customer MSTR'].INACTIVE) AS Inactive, (SELECT RTRIM(ACTNUMST) AS Expr1 FROM dbo.GL00105 AS ['Account Index Master'] WHERE (ACTINDX = ['RM Customer MSTR'].RMIVACC)) AS [Inventory Account Number], dbo.DYN_FUNC_Boolean_All(['RM Customer MSTR'].KPCALHST) AS [Keep Calendar History], dbo.DYN_FUNC_Boolean_All(['RM Customer MSTR'].KPDSTHST) AS [Keep Distribution History], dbo.DYN_FUNC_Boolean_All(['RM Customer MSTR'].KPERHIST) AS [Keep Period History], dbo.DYN_FUNC_Boolean_All(['RM Customer MSTR'].KPTRXHST) AS [Keep Trx History], ['Customer Master Summary'].LASTAGED AS [Last Aged], ['Customer Master Summary'].LSTFCHAM AS [Last Finance Charge Amount], ['Customer Master Summary'].LSTNSFCD AS [Last NSF Check Date], ['Customer Master Summary'].LPYMTAMT AS [Last Payment Amount], ['Customer Master Summary'].LASTPYDT AS [Last Payment Date], ['Customer Master Summary'].LSTSTAMT AS [Last Statement Amount], ['Customer Master Summary'].LASTSTDT AS [Last Statement Date], ['Customer Master Summary'].LSTTRXAM AS [Last Transaction Amount], ['Customer Master Summary'].LSTTRXDT AS [Last Transaction Date], ['RM Customer MSTR'].MXWROFAM AS [Max Writeoff Amount], dbo.DYN_FUNC_Maximum_Writeoff_Type(['RM Customer MSTR'].MXWOFTYP) AS [Maximum Writeoff Type], ['RM Customer MSTR'].MINPYDLR AS [Minimum Payment Dollar], ['RM Customer MSTR'].MINPYPCT / 100.00 AS [Minimum Payment Percent], dbo.DYN_FUNC_Minimum_Payment_Type(['RM Customer MSTR'].MINPYTYP) AS [Minimum Payment Type], ['RM Customer MSTR'].MODIFDT AS [Modified Date], ['Customer Master Summary'].NCSCHPMT AS [Non Current Scheduled Payments], ['RM Customer MSTR'].NOTEINDX AS [Note Index], ['Customer Master Summary'].NUMADTPR AS [Number ADTP Documents - LYR], ['Customer Master Summary'].NUMADTPL AS [Number ADTP Documents - Life], ['Customer Master Summary'].NUMADTPY AS [Number ADTP Documents - Year], ['Customer Master Summary'].NONSFLIF AS [Number Of NSF Checks Life], ['Customer Master Summary'].NONSFYTD AS [Number Of NSF Checks YTD], ['Customer Master Summary'].ONORDAMT AS [On Order Amount], dbo.DYN_FUNC_Order_Fulfillment_Shortage_Default(['RM Customer MSTR'].ORDERFULFILLDEFAULT) AS [Order Fulfillment Shortage Default], RTRIM(['RM Customer MSTR'].PYMTRMID) AS [Payment Terms ID], RTRIM(['RM Customer MSTR'].PHONE2) AS [Phone 2], RTRIM(['RM Customer MSTR'].PHONE3) AS [Phone 3], dbo.DYN_FUNC_Post_Results_To_Customer(['RM Customer MSTR'].Post_Results_To) AS [Post Results To], RTRIM(['RM Customer MSTR'].PRCLEVEL) AS PriceLevel, RTRIM(['RM Customer MSTR'].PRBTADCD) AS [Primary Billto Address Code], RTRIM(['RM Customer MSTR'].PRSTADCD) AS [Primary Shipto Address Code], dbo.DYN_FUNC_Priority(['RM Customer MSTR'].CUSTPRIORITY) AS Priority, RTRIM(['RM Customer MSTR'].RATETPID) AS [Rate Type ID], ['Customer Master Summary'].RETAINAG AS Retainage, dbo.DYN_FUNC_Boolean_All(['RM Customer MSTR'].Revalue_Customer) AS [Revalue Customer], (SELECT RTRIM(ACTNUMST) AS Expr1 FROM dbo.GL00105 AS ['Account Index Master'] WHERE (ACTINDX = ['RM Customer MSTR'].RMSLSACC)) AS [Sales Account Number], (SELECT RTRIM(ACTNUMST) AS Expr1 FROM dbo.GL00105 AS ['Account Index Master'] WHERE (ACTINDX = ['RM Customer MSTR'].RMSORACC)) AS [Sales Order Returns Account Number], RTRIM(['RM Customer MSTR'].SALSTERR) AS [Sales Territory], RTRIM(['RM Customer MSTR'].SLPRSNID) AS [Salesperson ID], dbo.DYN_FUNC_Boolean_All(['RM Customer MSTR'].Send_Email_Statements) AS [Send Email Statements], dbo.DYN_FUNC_Boolean_All(['RM Customer MSTR'].SHIPCOMPLETE) AS [Ship Complete Document], RTRIM(['RM Customer MSTR'].SHIPMTHD) AS [Shipping Method], RTRIM(['RM Customer MSTR'].SHRTNAME) AS [Short Name], RTRIM(['RM Customer MSTR'].STADDRCD) AS [Statement Address Code], dbo.DYN_FUNC_Statement_Cycle(['RM Customer MSTR'].STMTCYCL) AS [Statement Cycle], RTRIM(['RM Customer MSTR'].STMTNAME) AS [Statement Name], RTRIM(['RM Customer MSTR'].TAXEXMT1) AS [Tax Exempt 1], RTRIM(['RM Customer MSTR'].TAXEXMT2) AS [Tax Exempt 2], RTRIM(['RM Customer MSTR'].TXRGNNUM) AS [Tax Registration Number], RTRIM(['RM Customer MSTR'].TAXSCHID) AS [Tax Schedule ID], ['Customer Master Summary'].TTLFCLTD AS [Total # FC LTD], ['Customer Master Summary'].TTLFCLYR AS [Total # FC LYR], ['Customer Master Summary'].TTLFCYTD AS [Total # FC YTD], ['Customer Master Summary'].TTLINLTD AS [Total # Invoices LTD], ['Customer Master Summary'].TTLINLYR AS [Total # Invoices LYR], ['Customer Master Summary'].TTLINYTD AS [Total # Invoices YTD], ['Customer Master Summary'].TNSFCLIF AS [Total Amount Of NSF Checks Life], ['Customer Master Summary'].TNSFCYTD AS [Total Amount Of NSF Checks YTD], ['Customer Master Summary'].TBDDTLYR AS [Total Bad Deb LYR], ['Customer Master Summary'].TBDDTLTD AS [Total Bad Debt LTD], ['Customer Master Summary'].TBDDTYTD AS [Total Bad Debt YTD], ['Customer Master Summary'].TCSHRLTD AS [Total Cash Received LTD], ['Customer Master Summary'].TCSHRLYR AS [Total Cash Received LYR], ['Customer Master Summary'].TCSHRYTD AS [Total Cash Received YTD], ['Customer Master Summary'].TCOSTLTD AS [Total Costs LTD], ['Customer Master Summary'].TCOSTLYR AS [Total Costs LYR], ['Customer Master Summary'].TCOSTYTD AS [Total Costs YTD], ['Customer Master Summary'].TDISAYTD AS [Total Discounts Available YTD], ['Customer Master Summary'].TDTKNLTD AS [Total Discounts Taken LTD], ['Customer Master Summary'].TDTKNLYR AS [Total Discounts Taken LYR], ['Customer Master Summary'].TDTKNYTD AS [Total Discounts Taken YTD], ['Customer Master Summary'].TFNCHLTD AS [Total Finance Charges LTD], ['Customer Master Summary'].TFNCHLYR AS [Total Finance Charges LYR], ['Customer Master Summary'].TFNCHYTD AS [Total Finance Charges YTD], ['Customer Master Summary'].TTLRTLTD AS [Total Returns LTD], ['Customer Master Summary'].TTLRTLYR AS [Total Returns LYR], ['Customer Master Summary'].TTLRTYTD AS [Total Returns YTD], ['Customer Master Summary'].TTLSLLTD AS [Total Sales LTD], ['Customer Master Summary'].TTLSLLYR AS [Total Sales LYR], ['Customer Master Summary'].TTLSLYTD AS [Total Sales YTD], ['Customer Master Summary'].TWVFCLTD AS [Total Waived FC LTD], ['Customer Master Summary'].TWVFCLYR AS [Total Waived FC LYR], ['Customer Master Summary'].TWVFCYTD AS [Total Waived FC YTD], ['Customer Master Summary'].TWROFLTD AS [Total Writeoffs LTD], ['Customer Master Summary'].TWROFLYR AS [Total Writeoffs LYR], ['Customer Master Summary'].TWROFYTD AS [Total Writeoffs YTD], RTRIM(['RM Customer MSTR'].UPSZONE) AS [UPS Zone], ['Customer Master Summary'].UPFCHYTD AS [Unpaid Finance Charges YTD], ['Customer Master Summary'].UNPSTDCA AS [Unposted Cash Amount], ['Customer Master Summary'].UNPSTOCA AS [Unposted Other Cash Amount], ['Customer Master Summary'].UNPSTOSA AS [Unposted Other Sales Amount], ['Customer Master Summary'].UNPSTDSA AS [Unposted Sales Amount], RTRIM(['RM Customer MSTR'].USERDEF1) AS [User Defined 1], RTRIM(['RM Customer MSTR'].USERDEF2) AS [User Defined 2], ['Customer Master Summary'].WROFSLIF AS [Write Offs LIFE], ['Customer Master Summary'].WROFSLYR AS [Write Offs LYR], ['Customer Master Summary'].WROFSYTD AS [Write Offs YTD], (SELECT RTRIM(ACTNUMST) AS Expr1 FROM dbo.GL00105 AS ['Account Index Master'] WHERE (ACTINDX = ['RM Customer MSTR'].RMWRACC)) AS [Writeoff Account Number], 'dgpp://DGPB/?Db=&Srv=SQL&Cmp=SMC&Prod=0' + dbo.dgppAccountIndex(1, ['RM Customer MSTR'].RMARACC) AS [Accounts Receivable Account Number For Drillback], 'dgpp://DGPB/?Db=&Srv=SQL&Cmp=SMC&Prod=0' + dbo.dgppAccountIndex(1, ['RM Customer MSTR'].RMCSHACC) AS [Cash Account Number For Drillback], 'dgpp://DGPB/?Db=&Srv=SQL&Cmp=SMC&Prod=0' + dbo.dgppCheckbookID(1, ['RM Customer MSTR'].CHEKBKID) AS [Checkbook ID For Drillback], 'dgpp://DGPB/?Db=&Srv=SQL&Cmp=SMC&Prod=0' + dbo.dgppAccountIndex(1, ['RM Customer MSTR'].RMCOSACC) AS [COGS Account Number For Drillback], 'dgpp://DGPB/?Db=&Srv=SQL&Cmp=SMC&Prod=0' + dbo.dgppCustomerID(1, ['RM Customer MSTR'].CUSTNMBR) AS [Customer Number For Drillback], 'dgpp://DGPB/?Db=&Srv=SQL&Cmp=SMC&Prod=0' + dbo.dgppAccountIndex(1, ['RM Customer MSTR'].RMAVACC) AS [Discounts Available Account Number For Drillback], 'dgpp://DGPB/?Db=&Srv=SQL&Cmp=SMC&Prod=0' + dbo.dgppAccountIndex(1, ['RM Customer MSTR'].RMTAKACC) AS [Discounts Taken Account Number For Drillback], 'dgpp://DGPB/?Db=&Srv=SQL&Cmp=SMC&Prod=0' + dbo.dgppAccountIndex(1, ['RM Customer MSTR'].RMFCGACC) AS [Finance Charge Account Number For Drillback], 'dgpp://DGPB/?Db=&Srv=SQL&Cmp=SMC&Prod=0' + dbo.dgppAccountIndex(1, ['RM Customer MSTR'].RMIVACC) AS [Inventory Account Number For Drillback], 'dgpp://DGPB/?Db=&Srv=SQL&Cmp=SMC&Prod=0' + dbo.dgppAccountIndex(1, ['RM Customer MSTR'].RMSLSACC) AS [Sales Account Number For Drillback], 'dgpp://DGPB/?Db=&Srv=SQL&Cmp=SMC&Prod=0' + dbo.dgppAccountIndex(1, ['RM Customer MSTR'].RMSORACC) AS [Sales Order Returns Account Number For Drillback], 'dgpp://DGPB/?Db=&Srv=SQL&Cmp=SMC&Prod=0' + dbo.dgppSalespersonID(1, ['RM Customer MSTR'].SLPRSNID, 2) AS [Salesperson ID For Drillback], 'dgpp://DGPB/?Db=&Srv=SQL&Cmp=SMC&Prod=0' + dbo.dgppAccountIndex(1, ['RM Customer MSTR'].RMWRACC) AS [Writeoff Account Number For Drillback] FROM dbo.RM00101 AS ['RM Customer MSTR'] WITH (NOLOCK) LEFT OUTER JOIN dbo.RM00103 AS ['Customer Master Summary'] WITH (NOLOCK) ON ['RM Customer MSTR'].CUSTNMBR = ['Customer Master Summary'].CUSTNMBR