Bilanzbelege_O21_csv.sql 3.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. select T1."ACCT_NR" as "Acct Nr",
  2. T1."LEDGER_ACCTS_NAME" as "Ledger Accts Name",
  3. T1."LEDGER_ACCTS_NAME2" as "Ledger Accts Name2",
  4. T1."HANDLER" as "Handler_2",
  5. T1."DEPT_SPLIT" as "Dept Split",
  6. T1."TYPE_ACCTT" as "Type Acctt",
  7. T2."ACCT_NO" as "Acct No",
  8. T2."BOOKKEEP_DATE" as "Bookkeep Date",
  9. T2."BOOKKEEP_PERIOD" as "Bookkeep Period",
  10. T2."DOCUMENT_NO" as "Document No",
  11. T2."ORIGIN" as "Origin",
  12. T2."STATUS" as "Status",
  13. T2."DEBIT_AMOUNT" as "Debit Amount",
  14. T2."CREDIT_AMOUNT" as "Credit Amount",
  15. T2."DEBIT_QUANTITY" as "Debit Quantity",
  16. T2."CREDIT_QUANTITY" as "Credit Quantity",
  17. T2."AA_TRTYPE" as "Aa Trtype",
  18. T2."DEPARTMENT" as "Department",
  19. T2."STOCK" as "Stock",
  20. T2."MAKE_FAMILY" as "Make Family",
  21. T2."MAKE" as "Make",
  22. T2."VEHICLE_TYPE" as "Vehicle Type",
  23. T2."MODEL_LINE" as "Model Line",
  24. T2."FACTORY_MODEL" as "Factory Model",
  25. T2."WORKSHOP_MODEL" as "Workshop Model",
  26. T2."PRODUCT_GROUP" as "Product Group",
  27. T2."REPAIR_GROUP" as "Repair Group",
  28. T2."KIT_GROUP" as "Kit Group",
  29. T2."TIME_CODE" as "Time Code",
  30. T2."INT_VOUCHER_NO" as "Int Voucher No",
  31. T2."BALANCING_MARK" as "Balancing Mark",
  32. T2."USED_VEH_DEST_CODE" as "Used Veh Dest Code",
  33. T2."USE_OF_VEHICLE" as "Use Of Vehicle",
  34. T2."ACCT_NO_NEXT_CHART" as "Acct No Next Chart",
  35. T3."REFERENCE_IDENT" as "Reference Ident",
  36. T3."TRANSACT_DATE" as "Transact Date",
  37. T3."HANDLER" as "Handler",
  38. T3."PROGRAM" as "Program",
  39. T3."FUNCTION_CODE" as "Function Code",
  40. T3."MODUL" as "Modul",
  41. T3."DOCUMENT_KEY" as "Document Key",
  42. T3."COMMENT" as "Comment",
  43. T4."DEPARTMENT_TYPE_ID" as "Department Type Id",
  44. T4."DESCRIPTION" as "Description_2",
  45. T4."DEPARTMENT_GROUP" as "Department Group",
  46. T5."AA_TRTYPE_ID" as "Aa Trtype Id",
  47. T5."DESCRIPTION" as "Description",
  48. T5."OWN_DESCRIPTION" as "Own Description",
  49. T1."CLIENT_DB" as "Rechtseinheit",
  50. CASE WHEN (T2."DEPARTMENT" = ' ') THEN ('01') ELSE ((left(T4."DEPARTMENT_TYPE_ID",2))) END as "Betrieb",
  51. (substring(T4."DEPARTMENT_TYPE_ID", 3, 1)) as "Marke_ori_",
  52. T2."DEBIT_AMOUNT" + T2."CREDIT_AMOUNT" as "Betrag",
  53. T2."DEBIT_QUANTITY" + T2."CREDIT_QUANTITY" as "Menge",
  54. (db_name()) as "Mandant",
  55. (left(T1."ACCT_NR",1)) as "Susa",
  56. '' as "Text",
  57. T6."Hauptbetrieb_ID" as "Rechtseinheit_ID_ori",
  58. T6."Hauptbetrieb_Name" as "Rechtseinheit_Name_ori",
  59. T6."Standort_ID" as "Betrieb_ID_ori",
  60. T6."Standort_Name" as "Betrieb_Name_ori",
  61. T7."Fabrikat" as "Marke_ori",
  62. T7."Order_By" as "Fabrikat_Order_By_ori",
  63. T6."Hauptbetrieb_ID" as "Rechtseinheit_ID",
  64. T6."Hauptbetrieb_Name" as "Rechtseinheit_Name",
  65. T6."Standort_ID" as "Betrieb_ID",
  66. T6."Standort_Name" as "Betrieb_Name",
  67. T7."Fabrikat" as "Marke",
  68. T7."Order_By" as "Fabrikat_Order_By"
  69. from "OPTIMA"."import"."ACCOUNT_INFO" T1,
  70. "OPTIMA"."import"."ACCT_DOC_DATA" T3,
  71. (((("OPTIMA"."import"."ACCT_DOC_KEY" T2 left outer join "OPTIMA"."import"."DEPARTMENT_TYPE" T4 on (T2."DEPARTMENT" = T4."DEPARTMENT_TYPE_ID") and (T2."CLIENT_DB" = T4."CLIENT_DB")) left outer join "OPTIMA"."import"."AA_TRTYPE" T5 on (T2."AA_TRTYPE" = T5."AA_TRTYPE_ID") and (T2."CLIENT_DB" = T5."CLIENT_DB")) left outer join "OPTIMA"."data"."GC_Department" T6 on ((substring(T2."DEPARTMENT", 1, 2)) = T6."Standort") and (T2."CLIENT_DB" = T6."Hauptbetrieb_ID")) left outer join "OPTIMA"."data"."GC_Marken" T7 on (T2."CLIENT_DB" = T7."Client_DB") and ((substring(T2."DEPARTMENT", 3, 1)) = T7."Stelle_3_Department"))
  72. where ((T1."ACCT_NR" = T2."ACCT_NO") and (T1."CLIENT_DB" = T2."CLIENT_DB")) and ((T2."UNIQUE_IDENT" = T3."REFERENCE_IDENT") and (T2."CLIENT_DB" = T3."CLIENT_DB"))
  73. and ((T1."TYPE_ACCTT" = '1') and (T2."BOOKKEEP_DATE" >= convert(datetime, '2013-01-01 00:00:00.000')))
  74. -- order by "Acct Nr" asc