In Bearbeitung Artikelverwaltung -> Retourenübersicht nach Plattform und Zeit

Thomas Lisson

Administrator
Mitarbeiter
24. März 2006
15.574
300
Köln
Hi zusammen,

anbei eine Übersicht über Retouren zum ausgewählten Artikel in der Artikelverwaltung. So könnt ihr schnell sehen, über welche Plattform die meisten Retouren kommen oder ab wann sie sich häufen, etc.
Berücksichtigt werden alle Retouren - egal in welchem Status sie sind. Für die Retourenquote werden alle Verkäufe gezählt - unabhängig davon, ob die Bestellungen ausgeliefert wurden.

SQL:
SELECT    tPlattform.cName AS 'Plattform',
        ISNULL(jAktMonat.rm, 0) AS 'Akt. Monat',
        ISNULL(jVorMonat.rm, 0) AS 'Vormonat',
        ISNULL(jLetzte30Tage.rm, 0) AS 'Letzte 30 Tage',
        ISNULL(jLetzte3Monate.rm, 0) AS 'Letzte 3 Monate',    
        ISNULL(jAktJahr.rm, 0) AS 'Akt. Jahr',
        ISNULL(jLetzte365Tage.rm, 0) AS 'Letzte 365 Tage',
        ISNULL(jVorjahr.rm, 0) AS 'Vorjahr',
        ISNULL(jGesamt.rm, 0) AS 'Gesamt',
        ISNULL(jRetourenGesamt.Retourenquote, '0%') AS 'Retourenquote'
FROM tPlattform
LEFT JOIN (
    SELECT    nPlatform,
            ROUND(CONVERT(FLOAT, ISNULL(SUM(tRMRetourePos.fAnzahl), 0.0)), 2) AS rm
    FROM tbestellung
    JOIN tRMRetoure ON tRMRetoure.kBestellung = tBestellung.kBestellung
    JOIN tRMRetourePos ON tRMRetourePos.kRMRetoure = tRMRetoure.kRMRetoure
    WHERE    tRMRetourePos.kArtikel = @Key
            AND YEAR(tRMRetoure.dErstellt) = YEAR(getdate())
            AND MONTH(tRMRetoure.dErstellt) = MONTH(getdate())
    GROUP BY nPlatform
) as jAktMonat on jAktMonat.nPlatform = tPlattform.nPlattform
LEFT JOIN (
    SELECT    nPlatform,
            ROUND(CONVERT(FLOAT, ISNULL(SUM(tRMRetourePos.fAnzahl), 0.0)), 2) AS rm
    FROM tbestellung
    JOIN tRMRetoure ON tRMRetoure.kBestellung = tBestellung.kBestellung
    JOIN tRMRetourePos ON tRMRetourePos.kRMRetoure = tRMRetoure.kRMRetoure
    WHERE    tRMRetourePos.kArtikel = @Key
            AND YEAR(tRMRetoure.dErstellt) = YEAR(DATEADD(MONTH, -1, getdate()))
            AND MONTH(tRMRetoure.dErstellt) = MONTH(DATEADD(MONTH, -1, getdate()))
    GROUP BY nPlatform
) as jVorMonat on jVorMonat.nPlatform = tPlattform.nPlattform
LEFT JOIN (
    SELECT    nPlatform,
            ROUND(CONVERT(FLOAT, ISNULL(SUM(tRMRetourePos.fAnzahl), 0.0)), 2) AS rm
    FROM tbestellung
    JOIN tRMRetoure ON tRMRetoure.kBestellung = tBestellung.kBestellung
    JOIN tRMRetourePos ON tRMRetourePos.kRMRetoure = tRMRetoure.kRMRetoure
    WHERE    tRMRetourePos.kArtikel = @Key
            AND tRMRetoure.dErstellt > DATEADD(DAY, -30, getdate())
    GROUP BY nPlatform
) as jLetzte30Tage on jLetzte30Tage.nPlatform = tPlattform.nPlattform
LEFT JOIN (
    SELECT    nPlatform,
            ROUND(CONVERT(FLOAT, ISNULL(SUM(tRMRetourePos.fAnzahl), 0.0)), 2) AS rm
    FROM tbestellung
    JOIN tRMRetoure ON tRMRetoure.kBestellung = tBestellung.kBestellung
    JOIN tRMRetourePos ON tRMRetourePos.kRMRetoure = tRMRetoure.kRMRetoure
    WHERE    tRMRetourePos.kArtikel = @Key
            AND tRMRetoure.dErstellt > DATEADD(MONTH, -3, getdate())
    GROUP BY nPlatform
) as jLetzte3Monate on jLetzte3Monate.nPlatform = tPlattform.nPlattform
LEFT JOIN (
    SELECT    nPlatform,
            ROUND(CONVERT(FLOAT, ISNULL(SUM(tRMRetourePos.fAnzahl), 0.0)), 2) AS rm
    FROM tbestellung
    JOIN tRMRetoure ON tRMRetoure.kBestellung = tBestellung.kBestellung
    JOIN tRMRetourePos ON tRMRetourePos.kRMRetoure = tRMRetoure.kRMRetoure
    WHERE    tRMRetourePos.kArtikel = @Key
            AND YEAR(tRMRetoure.dErstellt) = YEAR(getdate())
    GROUP BY nPlatform
) as jAktJahr on jAktJahr.nPlatform = tPlattform.nPlattform
LEFT JOIN (
    SELECT    nPlatform,
            ROUND(CONVERT(FLOAT, ISNULL(SUM(tRMRetourePos.fAnzahl), 0.0)), 2) AS rm
    FROM tbestellung
    JOIN tRMRetoure ON tRMRetoure.kBestellung = tBestellung.kBestellung
    JOIN tRMRetourePos ON tRMRetourePos.kRMRetoure = tRMRetoure.kRMRetoure
    WHERE    tRMRetourePos.kArtikel = @Key
            AND tRMRetoure.dErstellt > DATEADD(DAY, -365, getdate())
    GROUP BY nPlatform
) as jLetzte365Tage on jLetzte365Tage.nPlatform = tPlattform.nPlattform
LEFT JOIN (
    SELECT    nPlatform,
            ROUND(CONVERT(FLOAT, ISNULL(SUM(tRMRetourePos.fAnzahl), 0.0)), 2) AS rm
    FROM tbestellung
    JOIN tRMRetoure ON tRMRetoure.kBestellung = tBestellung.kBestellung
    JOIN tRMRetourePos ON tRMRetourePos.kRMRetoure = tRMRetoure.kRMRetoure
    WHERE    tRMRetourePos.kArtikel = @Key
            AND YEAR(tRMRetoure.dErstellt) = YEAR(DATEADD(YEAR, -1, getdate()))
    GROUP BY nPlatform
) as jVorjahr on jVorjahr.nPlatform = tPlattform.nPlattform
JOIN (
    SELECT    nPlatform,
            ROUND(CONVERT(FLOAT, ISNULL(SUM(tRMRetourePos.fAnzahl), 0.0)), 2) AS rm
    FROM tbestellung
    JOIN tRMRetoure ON tRMRetoure.kBestellung = tBestellung.kBestellung
    JOIN tRMRetourePos ON tRMRetourePos.kRMRetoure = tRMRetoure.kRMRetoure
    WHERE    tRMRetourePos.kArtikel = @Key
    GROUP BY nPlatform
) as jGesamt on jGesamt.nPlatform = tPlattform.nPlattform
LEFT JOIN (
SELECT jabsatzgesamt.nPlatform,
        CONCAT(ROUND((ISNULL(retourengesamt.rm, 0.0)/jabsatzgesamt.absatz)*100, 2), '%') as Retourenquote
FROM
(SELECT tbestellung.nPlatform,
    ROUND(CONVERT(FLOAT, ISNULL(SUM(tbestellpos.nAnzahl), 0.0)), 2) AS absatz
    FROM tbestellung
    JOIN tbestellpos ON tbestellpos.tBestellung_kBestellung = tBestellung.kBestellung
    WHERE tbestellpos.tArtikel_kArtikel = @Key
        AND tbestellung.cType = 'B'
        AND tBestellung.nStorno = 0 -- Stornierte Aufträge nicht beachten
    GROUP BY nPlatform) AS jabsatzgesamt
LEFT JOIN
    (SELECT nPlatform,
        ROUND(CONVERT(FLOAT, ISNULL(SUM(tRMRetourePos.fAnzahl), 0.0)), 2) AS rm
    FROM tbestellung
    JOIN tRMRetoure ON tRMRetoure.kBestellung = tBestellung.kBestellung
    JOIN tRMRetourePos ON tRMRetourePos.kRMRetoure = tRMRetoure.kRMRetoure
    WHERE    tRMRetourePos.kArtikel = @Key
    GROUP BY nPlatform) AS retourengesamt on retourengesamt.nPlatform=jabsatzgesamt.nPlatform)
        as jRetourenGesamt on jRetourenGesamt.nPlatform = tPlattform.nPlattform
UNION
SELECT 'Alle Plattformen' AS 'Plattform',
    (SELECT ROUND(CONVERT(FLOAT, ISNULL(SUM(tRMRetourePos.fAnzahl), 0.0)), 2) AS rm
    FROM tbestellung
    JOIN tRMRetoure ON tRMRetoure.kBestellung = tBestellung.kBestellung
    JOIN tRMRetourePos ON tRMRetourePos.kRMRetoure = tRMRetoure.kRMRetoure
    WHERE    tRMRetourePos.kArtikel = @Key
            AND YEAR(tRMRetoure.dErstellt) = YEAR(getdate())
            AND MONTH(tRMRetoure.dErstellt) = MONTH(getdate())) as 'Akt. Monat',
    (SELECT ROUND(CONVERT(FLOAT, ISNULL(SUM(tRMRetourePos.fAnzahl), 0.0)), 2) AS rm
    FROM tbestellung
    JOIN tRMRetoure ON tRMRetoure.kBestellung = tBestellung.kBestellung
    JOIN tRMRetourePos ON tRMRetourePos.kRMRetoure = tRMRetoure.kRMRetoure
    WHERE    tRMRetourePos.kArtikel = @Key
            AND YEAR(tRMRetoure.dErstellt) = YEAR(DATEADD(MONTH, -1, getdate()))
            AND MONTH(tRMRetoure.dErstellt) = MONTH(DATEADD(MONTH, -1, getdate()))) as 'Vormonat',
    (SELECT ROUND(CONVERT(FLOAT, ISNULL(SUM(tRMRetourePos.fAnzahl), 0.0)), 2) AS rm
    FROM tbestellung
    JOIN tRMRetoure ON tRMRetoure.kBestellung = tBestellung.kBestellung
    JOIN tRMRetourePos ON tRMRetourePos.kRMRetoure = tRMRetoure.kRMRetoure
    WHERE    tRMRetourePos.kArtikel = @Key
    AND tRMRetoure.dErstellt > DATEADD(DAY, -30, getdate())) as 'Letzte 30 Tage',
    (SELECT ROUND(CONVERT(FLOAT, ISNULL(SUM(tRMRetourePos.fAnzahl), 0.0)), 2) AS rm
    FROM tbestellung
    JOIN tRMRetoure ON tRMRetoure.kBestellung = tBestellung.kBestellung
    JOIN tRMRetourePos ON tRMRetourePos.kRMRetoure = tRMRetoure.kRMRetoure
    WHERE    tRMRetourePos.kArtikel = @Key
    AND tRMRetoure.dErstellt > DATEADD(MONTH, -3, getdate())) as 'Letzte 3 Monate',
    (SELECT ROUND(CONVERT(FLOAT, ISNULL(SUM(tRMRetourePos.fAnzahl), 0.0)), 2) AS rm
    FROM tbestellung
    JOIN tRMRetoure ON tRMRetoure.kBestellung = tBestellung.kBestellung
    JOIN tRMRetourePos ON tRMRetourePos.kRMRetoure = tRMRetoure.kRMRetoure
    WHERE    tRMRetourePos.kArtikel = @Key
    AND YEAR(tRMRetoure.dErstellt) = YEAR(getdate())) as 'Akt. Jahr',
    (SELECT ROUND(CONVERT(FLOAT, ISNULL(SUM(tRMRetourePos.fAnzahl), 0.0)), 2) AS rm
    FROM tbestellung
    JOIN tRMRetoure ON tRMRetoure.kBestellung = tBestellung.kBestellung
    JOIN tRMRetourePos ON tRMRetourePos.kRMRetoure = tRMRetoure.kRMRetoure
    WHERE    tRMRetourePos.kArtikel = @Key
    AND tRMRetoure.dErstellt > DATEADD(DAY, -365, getdate())) as 'Letzte 365 Tage',
    (SELECT ROUND(CONVERT(FLOAT, ISNULL(SUM(tRMRetourePos.fAnzahl), 0.0)), 2) AS rm
    FROM tbestellung
    JOIN tRMRetoure ON tRMRetoure.kBestellung = tBestellung.kBestellung
    JOIN tRMRetourePos ON tRMRetourePos.kRMRetoure = tRMRetoure.kRMRetoure
    WHERE    tRMRetourePos.kArtikel = @Key
    AND YEAR(tRMRetoure.dErstellt) = YEAR(DATEADD(YEAR, -1, getdate()))) as 'Vorjahr',
    (SELECT ROUND(CONVERT(FLOAT, ISNULL(SUM(tRMRetourePos.fAnzahl), 0.0)), 2) AS rm
    FROM tbestellung
    JOIN tRMRetoure ON tRMRetoure.kBestellung = tBestellung.kBestellung
    JOIN tRMRetourePos ON tRMRetourePos.kRMRetoure = tRMRetoure.kRMRetoure
    WHERE    tRMRetourePos.kArtikel = @Key) as 'Gesamt',
    (SELECT CONCAT(ROUND((retourengesamt.rm/jabsatzgesamt.absatz)*100, 2), '%') as Retourenquote
FROM
(SELECT ROUND(CONVERT(FLOAT, ISNULL(SUM(tRMRetourePos.fAnzahl), 0.0)), 2) AS rm
    FROM tbestellung
    JOIN tRMRetoure ON tRMRetoure.kBestellung = tBestellung.kBestellung
    JOIN tRMRetourePos ON tRMRetourePos.kRMRetoure = tRMRetoure.kRMRetoure
    WHERE    tRMRetourePos.kArtikel = @Key) AS retourengesamt
JOIN
    (SELECT ROUND(CONVERT(FLOAT, ISNULL(SUM(tbestellpos.nAnzahl), 0.0)), 2) AS absatz
    FROM tbestellung
    JOIN tbestellpos ON tbestellpos.tBestellung_kBestellung = tBestellung.kBestellung
    WHERE tbestellpos.tArtikel_kArtikel = @Key
        AND tbestellung.cType = 'B') AS jabsatzgesamt on 1=1) AS Retourenquote
ORDER BY Plattform

EDIT am 27.09.2019 um 21:50

Viel Spaß damit!
 

Anhänge

  • LVE_Retouren.png
    LVE_Retouren.png
    12,6 KB · Aufrufe: 91
Zuletzt bearbeitet:

ROGUE

Sehr aktives Mitglied
11. September 2013
432
55
Hallo Zusammen,

der Script wäre auf jeden Fall mega geil. Nur leider funktioniert es nicht bei der Wawi 1.6. Könnte vielleicht jemand den Script für die Wawi 1.6 anpassen und hier posten?
Das wäre super hilfreich.

Vielen Dank im Voraus.
 
  • Gefällt mir
Reaktionen: Weedmaster-Flash
Ähnliche Themen
Titel Forum Antworten Datum
Wichtig JTL-ShippingLabels 1.0: Support-Ende GLS/DPD und Migration von JTL-Start-Kunden nach dem 30. September News, Events und Umfragen 12
Neu Viele Opos nach Export per JTL2Datev im Datev User helfen Usern 0
Login nach Downgrade nicht möglich JTL-Wawi 1.11 1
Neu Amazonpay Fehler nach Anbindung von Datev - bitte helfen Schnittstellen Import / Export 0
Neu Neu angelegte Kategorien sind erst nach Anmeldung sichtbar Allgemeine Fragen zu JTL-Shop 1
Neu Shop und Worker synchronisieren nicht nach Wechsel zu Cloudflare Allgemeine Fragen zu JTL-Shop 0
In Diskussion Kundengruppe nach Umsatz (SQL in Workflow) JTL-Workflows - Ideen, Lob und Kritik 5
Neu Swissbit USB-TSE blinkt nach dem Herunterfahren dauerhaft. Einrichtung / Updates von JTL-POS 1
Amazon-Bestände werden nicht übertragen – Überverkäufe nach Reaktivierung aus Urlaubsmodus (Wawi 1.11.11) JTL-Wawi 1.11 1
Neu Vorgehen nach Sicherheitslücke im Shop - Wechsel Blowfish-Key Betrieb / Pflege von JTL-Shop 6
Neu Shop 5.7.2. nach Update lahm und CPU Last geht hoch Installation / Updates von JTL-Shop 1
Lizenzprobleme nach Update JTL-Wawi 1.8 6
Neu Versandart nach Volumengewicht und Lieferland Allgemeine Fragen zu JTL-Shop 2
Neu Consentmanager item youtube deaktiviert sich nach ShopUpdate Allgemeine Fragen zu JTL-Shop 2
Neu SUNMI V3 MIX – Touchscreen und USB-Maus frieren nach einigen Minuten ein JTL-POS - Fehler und Bugs 1
Neu 500er Fehler im Shop nach aktivierung des Nova Child Templates für JTL-Shop 3
Kundengruppenrabatte werden bei einzelnen Artikeln nicht übernommen – „Rabatte ignorieren“ springt nach Speichern zurück JTL-Wawi 2.0 2
nach Update von 5.3 auf 5.7 neue Position im Warenkorb "Gebühr" die auch in den Auftrag übernommen werden Einrichtung JTL-Shop5 2
Neu Wie übertragt ihr Kurzbeschreibungen nach Shopify? Shopify-Connector 5
Beantwortet Shop Abgleich nach Update auf 5.7.2 nicht mehr möglich JTL-Shop - Fehler und Bugs 4
Login Wawi nicht möglich nach Update auf 1.11.11 JTL-Wawi 1.11 1
Neu Nach Wawi Update Probleme mit Rechnungsdrucker JTL-POS - Fehler und Bugs 4
ändern von Servernamen nach Neuinstallation von SQL und Verbindung mit neuem Server in der Wawi JTL-Wawi 2.0 2
JTL APP - Fehlermeldung nach Update auf Wawi 1.11. JTL-Wawi App 6
Nach Wawi Update keine Fehlermeldung mehr sichtbar kaufland.de - Anbindung (SCX) 2
Nach Update auf 2.0.3 Keine Fehlermeldungen mehr sichtbar Otto.de - Anbindung (SCX) 3
Neu Update nach 5.7.1 hängt bei Mirgation Installation / Updates von JTL-Shop 4
JTL nach Update auf 2.0.3 im Bereich „Kunden“ extrem langsam JTL-Wawi 2.0 1
JTL-Wawi sucht falschen ShopType nach Gambio-Update JTL-Wawi 1.7 2
Nach update 1.8>1.11 Kein Mandant in JTL-Wawi gefunden JTL-Wawi 1.11 5
Neu Betrag auf der Rechnung nach Rechnungskorrektur User helfen Usern - Fragen zu JTL-Wawi 1
Fehler nach Update auf Version 1.11.11 und 2.0.4 JTL-Wawi 2.0 7
Neu DHL Versenden 4.0 - Versand nach USA - Parameter state must be between 1 and 20 characters long. JTL-ShippingLabels - Fehler und Bugs 1
Neu DHL Versenden 4.0 - Versand nach CH - Please enter a valid amount JTL-ShippingLabels - Fehler und Bugs 5
Neu OnFinds: KI-Suche für JTL-Shop mit fairer Abrechnung nach Artikelanzahl. 30 Tage kostenlos testen Plugins für JTL-Shop 10
Nach dem Update werden die Drucker nicht mehr erkannt JTL-Wawi 2.0 1
Neu Nach Update auf 1.11.10.0 Abgleich zu Ebay über 3 Stunden bei neuen Angeboten eBay-Anbindung - Fehler und Bugs 2
Beantwortet [WAWI-85758] Nach Update auf 1.11.10 klappt stornieren über ios Wawi App nicht mehr JTL-Workflows - Fehler und Bugs 1
Neu Nach Update auf JTL-Wawi 2.0.3 keine WMS-Lager mehr auswählbar – Versand komplett blockiert JTL-Wawi 2.0 3
Neu WAWI 2.0.2 Auftragsuche nach Ebay-Benutzernamen funktioniert nicht JTL-Wawi - Fehler und Bugs 1
Zugriff verweigert nach Umzug auf neuen Rechner, X-Rechnung kann nicht gespeichert werden JTL-Wawi 1.11 4
Neu Nach Update auf 1.11.9 - alle Shopify Shop nicht mehr connected Shopify-Connector 4
Neu Error 500 Fehler nach Dropper Installation Betrieb / Pflege von JTL-Shop 2
Neu Nach Update in Dez 2025 wird TSE Swissbit nicht mehr erkannt JTL-POS - Fehler und Bugs 1
Nach Update auf 2.0 auf einmal kostenpflichtig JTL-Wawi 2.0 2
Neu Produkt-Upload schlägt fehl nach Shopware-Update 6.7.9.0 – Fehler bei quantityStart (SaaS-Connector) Shopware-Connector 14

Ähnliche Themen