Service_Archiv_Rg_Ausgang_GWL.sql 1.1 KB

12345678910
  1. select distinct T1."No_" as "No",
  2. T1."Posting Date" as "Posting Date",
  3. T1."Document Date" as "Document Date",
  4. T2."Order No_" as "Order No",
  5. CASE WHEN (T2."Source No_ (Payment)" LIKE 'INT%') THEN ('Intern') WHEN (T2."Source No_ (Payment)" LIKE 'GARA%') THEN ('GWL') ELSE ('Extern') END as "Umsatzart"
  6. from "NAVISION"."import"."Archived_Service_Header" T1,
  7. "NAVISION"."import"."Service_Ledger_Entry" T2
  8. where ((T1."No_" = T2."Order No_") and (T1."Client_DB" = T2."Client_DB"))
  9. and ((((((T1."Document Type" <> 0) and ((-1 * datediff(day, (getdate()), T1."Posting Date")) <= 7)) and (T2."Entry Type" = 0)) and (T1."Gen_ Prod_ Posting Group" <> 'FEHLER')) and ((CASE WHEN (T1."Location Code" = 'MM') THEN ('10') WHEN (T1."Location Code" = 'VÖH') THEN ('20') WHEN (T1."Location Code" = 'KRU') THEN ('30') WHEN (T1."Location Code" = 'ULM') THEN ('40') WHEN (T1."Location Code" = 'LL') THEN ('50') ELSE null END) <> '20')) and ((CASE WHEN (T2."Source No_ (Payment)" LIKE 'INT%') THEN ('Intern') WHEN (T2."Source No_ (Payment)" LIKE 'GARA%') THEN ('GWL') ELSE ('Extern') END) = 'GWL'))
  10. -- order by "No" asc