Quantcast
Channel: SCN: Message List
Viewing all articles
Browse latest Browse all 2161

Stock Aging Report

$
0
0

Dear Experts,

 

I try get Stock aging report using this query, but fetching information is wrong. Could you please tell me what's wrong in this query?

 

select b.Code, b.Name,b.Grp, b.Wh, b.Bal, b.Val, isnull(case when b.days between 0 and 30 then b.bal end,0)'0-30 Days' ,

isnull(case when b.days between 0 and 30 then b.Val end,0) 'Value', isnull(case when b.days between 31 and 60 then b.bal end,0) '30-60 Days', isnull(case when b.days between 31 and 60 then b.Val end,0) 'Value', isnull(case when b.days between 61 and 90 then b.bal end,0) '60-90 Days', isnull(case when b.days between 61 and 90 then b.Val end,0) 'Value', isnull(case when b.days between 91 and 120 then b.bal end,0) '90-120 Days', isnull(case when b.days between 91 and 120 then b.Val end,0) 'Value', isnull(case when b.days between 121 and 150 then b.bal end,0) '120-150 Days', isnull(case when b.days between 121 and 150 then b.Val end,0) 'Value', isnull(case when b.days between 151 and 180 then b.bal end,0) '150-180 Days', isnull(case when b.days between 151 and 180 then b.Val end,0) 'Values', isnull(case when b.days >=181 then b.bal end,0) 'Above 180 Days', isnull(case when b.days >=181 then b.Val end,0) 'Value' from ( select a.code,a.name,a.grp,a.wh,a.bal,a.val,datediff(dd,dt,getdate())'days' from ( select max(t0.itemcode)'Code',max(t0.Dscription)'Name', max(t2. ItmsGrpNam) 'grp',max(t0.Warehouse)'Wh', max(t1.OnHand)'Bal',sum(t0.transvalue)'Val',max(t0.docdate)'dt' from oinm t0 inner join oitm t1 on t0.itemcode=t1.itemcode inner join oitb t2  on t1.ItmsGrpCod = t2.ItmsGrpCod group by t0.itemcode )a )b order by code


Viewing all articles
Browse latest Browse all 2161

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>