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

Query for Sales Analysis for Item

$
0
0

Hi Experts,

 

Does anyone know the query to get the exact result in SAP Analysis for Item vs. SQL Query result.

 

so far I have the query below. but that doesn't get the exact result the same as what shows in SAP.

 

 

select rawdata.itemcode [Item Code],ids.itemname [Item Description],sum(quantity) Quantity, sum(linetotal) [Sales Amount], sum(grssprofit) [Gross Profit],convert(numeric(19,3),(case when sum(linetotal) = 0 then -100 else (sum(grssprofit) / sum(linetotal))  * 100 end)) as [Gross Profit %] from (

select T1.itemcode,T1.quantity * (case when T1.objtype = 13 then 1 else -1 end) Quantity,T1.linetotal * (case when T1.objtype = 13 then 1 else -1 end) LineTotal,T1.grssprofit * (case when T1.objtype = 13 then 1 else -1 end) GrssProfit

from INV1 T1

left join OINV T0 on T0.docentry = T1.docentry

WHERE T0.DocDate between '08.01.2014' and '08.31.2014'

union all

select T1.itemcode,T1.quantity * (case when T1.objtype = 13 then 1 else -1 end) Quantity,T1.linetotal * (case when T1.objtype = 13 then 1 else -1 end) LineTotal,T1.grssprofit * (case when T1.objtype = 13 then 1 else -1 end) GrssProfit

from RIN1 T1

left join ORIN T0 on T0.docentry = T1.docentry

WHERE T0.DocDate between '08.01.2014' and '08.31.2014'

) as rawdata

left join OITM ids on ids.itemcode collate SQL_Latin1_General_CP1_CI_AS= rawdata.itemcode

where rawdata.itemcode is not null

group by rawdata.itemcode,ids.itemname

order by rawdata.itemcode

 

 

 

info: we are using SAP Business One 2007 A (8.00.181)  SP: 00  PL: 46

 

 

thanks in Advance.

 

Jim


Viewing all articles
Browse latest Browse all 9052

Trending Articles



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