I'm looking for a SQL query that will pull sales for a year with GL distribution AND the ship to state. Does this query look ok - I'm not sure about the joins
select
'xxx' COMPANY,
OPENYEAR Trx_Year,
TRXDATE Trx_Date,
JRNENTRY Journal_Entry,
ORTRXSRC Originating_TRX_Source,
ORMSTRID Originating_Master_ID,
ORMSTRNM Originating_Master_Name,
ORDOCNUM Originating_Doc_Number,
DEBITAMT Debit_Amount,
CRDTAMNT Credit_Amount,
ACTNUMST Account_Number,
ACTDESCR Account_Description,
ACCATDSC Account_Category,
ORPSTDDT originating_post_date,
ORIGNUMB SOPORIGNUMB,
STATE
from
(select ACTINDX, OPENYEAR, TRXDATE, JRNENTRY, ORTRXSRC, ORPSTDDT,
ORDOCNUM, ORMSTRID, ORMSTRNM, DEBITAMT, CRDTAMNT
from GL20000
where (SERIES = '3') and OPENYEAR = '2015') GL
inner join GL00105 GM
on GL.ACTINDX = GM.ACTINDX
inner join GL00100 GA
on GL.ACTINDX = GA.ACTINDX
inner join GL00102 C
on GA.ACCATNUM= C.ACCATNUM
inner join SOP30200 S
on GL.ORDOCNUM= S.ORIGNUMB
go
*This post is locked for comments