Databases Reference
In-Depth Information
23.5■Die Retourenquoten pro Style
Das dürte mittlerweile eine leichte Übung für Sie sein. Sie müssen nur noch oben bei den
gewünschten Ergebnissen zwischen der Retourensumme und den Retourengründen die
Berechnung der Retourenquote einfügen:
Cast(isnull(ret.Retouren,0)/ord.Anzahl*100 as DECIMAL(10,2)) RQ_Artikel
und
cast(isnull(ret.Retourensumme,0)/ord.Nettosumme*100 as DECIMAL(10,2))
RQ_Nettowert
Der komplette Select sieht wie folgt aus:
Select ord.Style, ord.Artikel,ord.Farbe, ord.Anzahl, ord.Nettosumme,
ret.Retouren, ret.Retourensumme,
cast(isnull(ret.Retouren,0)/ord.Anzahl*100 as DECIMAL(10,2)) RQ_Artikel,
Retourenquote Artikelmenge
cast(isnull(ret.Retourensumme,0)/ord.Nettosumme*100 as DECIMAL(10,2))
RQ_Nettowert, → Retourenquote Nettowert
rr.Reason, rr.Angaben
from
(SELECT a.article_No +'_'+ a.colorCode Style,
a.[description]Artikel, a.colorDescription Farbe,
SUM (s.quantity)Anzahl,
SUM (s.quantity*s.amount)Nettosumme
FROM [dbo].[iw_sales]s,[dbo].[iw_article]a
where s.IWAN = a.IWAN
and s.type = 2
and s.amount > 0
and s.orderDate between '01.10.2011' and '31.12.2011'
group by a.article_No +'_'+ a.colorCode ,
a.[description], a.colorDescription) ord, → Bestelldaten
(Select a.article_No +'_'+ a.colorCode Style,
a.[description], a.colorDescription,SUM (rl.quantity)Retouren,
SUM (rl.line_amount) Retourensumme
from [dbo].[iw_return_header]rh,[dbo].[iw_sales]s, [dbo].[iw_return_line]
rl,[dbo].[iw_article]a
where rh.orderNo = s.orderNo
and s.orderDate between '01.10.2011' and '31.12.2011'
and s.IWAN = rl.IWAN
and rh.returnNo = rl.returnNo
and rl.IWAN = a.IWAN
group by a.article_No +'_'+ a.colorCode ,
a.[description], a.colorDescription)ret, → Retourendaten
(SELECT a.article_No +'_'+ a.colorCode Style,
cr.Reason, COUNT (*)Angaben
FROM [dbo].[iw_return_header]rh,[dbo].[iw_sales]s,
[dbo].[iw_return_line]rl,
[dbo].[iw_codeReason]cr, [dbo].[iw_article]a
where rh.orderNo = s.orderNo
and s.orderDate between '01.10.2011' and '31.12.2011'
and s.IWAN = rl.IWAN
and rh.returnNo = rl.returnNo
and rl.returnReason = cr.Code
and rl.[Type] = 2
 
Search WWH ::




Custom Search