question

Bashadb18 avatar image
Bashadb18 asked

Need Help creating a 12 Month Trailing report

Hi All, Need help in generating report for Trailing Twelve Month (TTM)of data. SQL query is listed below. Any links if known would also be helpful. Thanks. select p.saddr1 PropAddr, p.scode scode, sum(t.smtd * case when a.neg = 0 then 1 else -1 end) Amount from total t inner join (select at.scode Tree , a.hmy ahmy , a.scode Acct , tot.sdesc AcctTot , ad.bnegate neg from accttree at inner join accttreedetail ad on ad.htree = at.hmy inner join accttreedetailxref adx on adx.hdetail = ad.hmy inner join accttreexref ax on ax.hdetail = ad.hmy inner join accttreedetail tot on tot.hmy = adx.htotal inner join acct a on a.hmy = ax.hacct Union All select Distinct at.scode Tree , a.hmy ahmy , a.scode Acct , ad.sdesc AcctTot , ad.bnegate neg from accttree at inner join accttreedetail ad on ad.htree = at.hmy inner join accttreedetailxref adx on adx.hdetail = ad.hmy inner join accttreexref ax on ax.hdetail = ad.hmy inner join acct a on a.hmy = ax.hacct Union All Select Distinct at.scode , a.hmy , a.scode , a.scode , ad.bnegate from accttree at inner join accttreedetail ad on ad.htree = at.hmy inner join accttreexref ax on ax.hdetail = ad.hmy inner join acct a on a.hmy = ax.hacct ) a on a.ahmy = t.hacct inner join property p on p.hmy = t.hppty inner join propattributes pa on pa.hproperty = p.hmy where 1 = 1 #Conditions# group by p.saddr1, p.scode
tsqlsql server 2012helpquery-analyzerremote procedure
10 |1200 characters needed characters left characters exceeded

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

0 Answers

· Write an Answer

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.