Query:StaticQuery |
USE BANKDB25
Select BANKDB25.dbo.TrustXref.TrustNo As TrustXref__TrustNo
, BANKDB25.dbo.TrustPerm.Name1 As TrustPerm__Name1,
BANKDB25.dbo.TrustPerm.Name1_Z As TrustPerm__Name1_Z
, BANKDB25.dbo.ElecFile.FedIndSt As ElecFile__FedIndSt
, BANKDB25.dbo.ElecFile.Filing_Cd As ElecFile__Filing_Cd
, BANKDB25.dbo.ElecFile.Fed_Status_Flg As ElecFile__Fed_Status_Flg
, ISNULL(BANKDB25.dbo.ElecFile.AttentionCd,0) As ElecFile__AttentionCd
, BANKDB25.dbo.ElecFile.TaxDue_Over As ElecFile__TaxDue_Over
, ISNULL(BANKDB25.dbo.TrustPerm.EFTPSBalDue_Fl,0) As TrustPerm__EFTPSBalDue_Fl
, BANKDB25.dbo.TrustPerm.Prep_Cd As TrustPerm__Prep_Cd,
BANKDB25.dbo.TrustPerm.Prep_Cd_Z As TrustPerm__Prep_Cd_Z
, BANKDB25.dbo.Trust.TxYrBegin_Dt As Trust__TxYrBegin_Dt
, ISNULL(BANKDB25.dbo.Trust.ChngType,0) As Trust__ChngType
, BANKDB25.dbo.Trust.EntityType As Trust__EntityType,
BANKDB25.dbo.TrustPerm.EntityType_Z As TrustPerm__EntityType_Z
, BANKDB25.dbo.Trust.PermSeq As Trust__PermSeq
, BANKDB25.dbo.Trust.PowerAmt As Trust__PowerAmt
, BANKDB25.dbo.Trust.PowerPct As Trust__PowerPct
, ISNULL(BANKDB25.dbo.Trust.ShortYrReason,0) As Trust__ShortYrReason
, ISNULL(BANKDB25.dbo.Trust.Ten991098_Fl,0) As Trust__Ten991098_Fl,
BANKDB25.dbo.TrustPerm.Ten991098_Fl_Z As TrustPerm__Ten991098_Fl_Z
, ISNULL(BANKDB25.dbo.Trust.Ten995498_Fl,0) As Trust__Ten995498_Fl,
BANKDB25.dbo.TrustPerm.Ten995498_Fl_Z As TrustPerm__Ten995498_Fl_Z
, ISNULL(BANKDB25.dbo.Trust.Ten99DIOB_Fl,0) As Trust__Ten99DIOB_Fl,
BANKDB25.dbo.TrustPerm.Ten99DIOB_Fl_Z As TrustPerm__Ten99DIOB_Fl_Z
, ISNULL(BANKDB25.dbo.Trust.Ten99MiscRR_Fl,0) As Trust__Ten99MiscRR_Fl,
BANKDB25.dbo.TrustPerm.Ten99MiscRR_Fl_Z As TrustPerm__Ten99MiscRR_Fl_Z
, ISNULL(BANKDB25.dbo.Trust.Ten99MiscSP_Fl,0) As Trust__Ten99MiscSP_Fl,
BANKDB25.dbo.TrustPerm.Ten99MiscSP_Fl_Z As TrustPerm__Ten99MiscSP_Fl_Z
, ISNULL(BANKDB25.dbo.Trust.Ten99R_Fl,0) As Trust__Ten99R_Fl,
BANKDB25.dbo.TrustPerm.Ten99R_Fl_Z As TrustPerm__Ten99R_Fl_Z
, BANKDB25.dbo.Trust.TrustKey As Trust__TrustKey
, BANKDB25.dbo.Trust.TxYrEnd_Dt As Trust__TxYrEnd_Dt,
BANKDB25.dbo.TrustPerm.TxYrEnd_Dt_Z As TrustPerm__TxYrEnd_Dt_Z
, BANKDB25.dbo.Trust.YrSeq As Trust__YrSeq
, ISNULL(BANKDB25.dbo.TrustPerm.CSplitType_Cd,0) As TrustPerm__CSplitType_Cd,
BANKDB25.dbo.TrustPerm.CSplitType_Cd_Z As TrustPerm__CSplitType_Cd_Z
, ISNULL(BANKDB25.dbo.TrustPerm.EASY_Fl,0) As TrustPerm__EASY_Fl
, BANKDB25.dbo.TrustPerm.Locator As TrustPerm__Locator
, BANKDB25.dbo.TrustPerm.Locator5x5 As TrustPerm__Locator5x5
, ISNULL(BANKDB25.dbo.TrustPerm.RelatedType,0) As TrustPerm__RelatedType
, BANKDB25.dbo.TrustPerm.YETaxType As TrustPerm__YETaxType,
BANKDB25.dbo.TrustPerm.YETaxType_Z As TrustPerm__YETaxType_Z
, ISNULL(BANKDB25.dbo.TrustPerm.EFExclude_Fl,0) As TrustPerm__EFExclude_Fl
, ISNULL(BANKDB25.dbo.TrustPerm.EFStExclude_Fl,0) As TrustPerm__EFStExclude_Fl
, BANKDB25.dbo.TrustXref.AcctNo As TrustXref__AcctNo
, BANKDB25.dbo.TaxStats.FedType_Cd As TaxStats__FedType_Cd
, BANKDB25.dbo.TaxStats.InsolSeqNo As TaxStats__InsolSeqNo
, BANKDB25.dbo.TaxStats.SeqNo As TaxStats__SeqNo
, BANKDB25.dbo.TaxStats.TrustKey As TaxStats__TrustKey
, BANKDB25.dbo.TaxStats.YrSeq As TaxStats__YrSeq
, BANKDB25.dbo.TrustPerm.PermSeq As TrustPerm__PermSeq
, BANKDB25.dbo.TrustPerm.TrustKey As TrustPerm__TrustKey
, BANKDB25.dbo.TrustXref.TrustKey As TrustXref__TrustKey
, BANKDB25.dbo.TrustYr.TrustKey As TrustYr__TrustKey
, BANKDB25.dbo.TrustYr.YrSeq As TrustYr__YrSeq
, BANKDB25.dbo.TaxStats.ChngType As TaxStats__ChngType
, BANKDB25.dbo.TrustPerm.ChngType As TrustPerm__ChngType
, BANKDB25.dbo.TrustYr.ChngType As TrustYr__ChngType
,BankDB='BANKDB25'
--,autokey=identity(int,1,1),RecordChanged_Fl=0,RecordSelected_Fl=0
--Into BTMFILEDB..RT20180601184728077467PIN5010DT
From BANKDB25.dbo.TrustXref
JOIN BANKDB25.dbo.TrustPerm ON BANKDB25.dbo.TrustXref.TrustKey = BANKDB25.dbo.TrustPerm.TrustKey
JOIN BANKDB25.dbo.Trust ON BANKDB25.dbo.TrustPerm.TrustKey = BANKDB25.dbo.Trust.TrustKey
AND BANKDB25.dbo.TrustPerm.PermSeq = BANKDB25.dbo.Trust.PermSeq
LEFT JOIN BANKDB25.dbo.TrustYr ON BANKDB25.dbo.Trust.TrustKey = BANKDB25.dbo.TrustYr.TrustKey
AND BANKDB25.dbo.Trust.YrSeq = BANKDB25.dbo.TrustYr.YrSeq
JOIN BANKDB25.dbo.ElecFile ON BANKDB25.dbo.Trust.TrustKey = BANKDB25.dbo.ElecFile.TrustKey
AND BANKDB25.dbo.Trust.YrSeq = BANKDB25.dbo.ElecFile.YrSeq
AND ISNULL(BANKDB25.dbo.ElecFile.InsolSeqNo,0) = 0
LEFT JOIN BANKDB25.dbo.TaxStats ON BANKDB25.dbo.Trust.TrustKey = BANKDB25.dbo.TaxStats.TrustKey
AND BANKDB25.dbo.Trust.YrSeq = BANKDB25.dbo.TaxStats.YrSeq
AND ISNULL(BANKDB25.dbo.TaxStats.FedType_Cd,0) = 0
AND ISNULL(BANKDB25.dbo.ElecFile.InsolSeqNo,0) = ISNULL(BANKDB25.dbo.TaxStats.InsolSeqNo,0)
AND BANKDB25.dbo.ElecFile.Compute_Dt_Tm = BANKDB25.dbo.TaxStats.Compute_Dt
AND ISNULL(BANKDB25.dbo.TaxStats.Projection_Fl,0) = 0
Where ((BANKDB25.dbo.Trust.ChngType <> 3 OR BANKDB25.dbo.Trust.ChngType IS NULL)
And BANKDB25.dbo.ElecFile.FedIndSt = 'FED'
And (BANKDB25.dbo.ElecFile.Fed_Status_Flg = 'C'
Or BANKDB25.dbo.ElecFile.Fed_Status_Flg = 'P
'
Or ISNULL(BANKDB25.dbo.ElecFile.AttentionCd,0) <> 0)
)
And (BANKDB25.dbo.TrustXref.AcctNo = '5010'
And BANKDB25.dbo.Trust.YrSeq >= 20170
And BANKDB25.dbo.Trust.YrSeq <= 20179
)
Order By TrustXref__TrustNo ASC
|