Databases Reference
In-Depth Information
and cr.Type = 'returnReason'
and rl.IWAN = a.IWAN
group by a.article_No +'_'+ a.colorCode , cr.Reason)rr
Retourengründe
where ord.Style = ret.Style
and ord.Style = rr.Style
23.6■Einschränkungen nach Retourenquote
Unser Retourentreiber-Report ist so gut wie fertig. Wir wollen allerdings die Ausgabe der
Daten auf die Artikel bzw. Styles beschränken, die eine recht hohe Retourenquote haben.
Nehmen wir als Beispiel eine Retourenquote von mindestens 85 %.
Select * from → Alles von der Unterabfrage ausgeben
Klammer auf!
(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,
cast(isnull(ret.Retourensumme,0)/ord.Nettosumme*100 as DECIMAL(10,2))
RQ_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,
(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,
(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
 
Search WWH ::




Custom Search