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
Neu Nach Update auf 1.11.10.0 Abgleich zu Ebay über 3 Stunden bei neuen Angeboten eBay-Anbindung - Fehler und Bugs 2
Neu Nach Update auf 1.11.10 klappt stornieren über ios Wawi App nicht mehr JTL-Workflows - Fehler und Bugs 0
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 2
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 Druck nach jeder Position JTL-POS - Fragen zu Hardware 1
Neu Nach Umstellung DHL Versenden 4.0 wird Kleinpaket nun auf DHL Paket Labeldrucker ausgegeben statt auf Kleinpaketdrucker JTL-ShippingLabels - Fehler und Bugs 14
Inaktive Verkaufskanäle lassen sich nicht löschen – erscheinen nach Löschen und Speichern erneut JTL-Wawi 1.11 2
Nach Update auf 2.01 kein Worker mehr JTL-Wawi 2.0 13
Neu JTL Pos liest keine Verkäufe mehr ein nach Update Einrichtung / Updates von JTL-POS 0
Nach Update auf Wawi 2.0.X, API v1 Fehler JTL-Wawi 2.0 9
Neu SQL-Server geht eine Stunde nach Allgemeine Fragen zu JTL-Shop 4
Neu eBay-Vorlage übernimmt alten Artikelnamen nach Duplizieren – Bug oder Bedienfehler? JTL-Wawi - Fehler und Bugs 2
Login Zeiten nach User in Wawi 1.6 JTL-Wawi 1.6 0
Neu Problem nach Update auf Shop 5.6.1 - Impressum JTL-Shop - Fehler und Bugs 2
Neu Fehlermeldung nach der Umstellung von DHL Versenden 4.0 JTL-Track&Trace - Fehler und Bugs 10
Neu Refresh nach Abgleich User helfen Usern - Fragen zu JTL-Wawi 0
Neu Artikel letzte 10 Versanddaten, sortiert nach Datum mit Plattform Eigene Übersichten in der JTL-Wawi 4
Neu Stücklisten nach Artikelkopie nicht mehr direkt änderbar – Bug oder gewollte Änderung? JTL-Wawi - Fehler und Bugs 1
Neu Strukturierte Daten vom Typ "Produkt" werden nach Update auf JTL Shop 5.6.1 nur fehlerhaft erkannt JTL-Shop - Fehler und Bugs 3
Neu JTL POS - nach Gerätetausch - Standard-Datenbank hinterlegen Einrichtung / Updates von JTL-POS 1
Neu Pickliste nach Teillieferung automatisch löschen Arbeitsabläufe in JTL-WMS / JTL-Packtisch+ 0
Neu Was genau passiert nach dem zurücksetzen? WooCommerce-Connector 0
Neu DSGVO – Automatisierte Löschung von Kundendaten nach 10 Jahren (JTL-Wawi / JTL-Shop) User helfen Usern - Fragen zu JTL-Wawi 2
Neu nach Update nicht alle Rechnungen mehr an Amazon Amazon-Anbindung - Fehler und Bugs 0
Neu OPC friert beim speichern von Änderungen ein nach JTL-Shop Update von Version 5.1.5 auf 5.6.1 JTL-Shop - Fehler und Bugs 6

Ähnliche Themen