NW_GW_VK_GW_final.iqd 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202
  1. COGNOS QUERY
  2. STRUCTURE,1,1
  3. DATABASE,GC_AUTOLINE
  4. DATASOURCENAME,C:\GlobalCube\System\Autoline\IQD\nw\NW_GW_VK_GW_final.imr
  5. TITLE,NW_GW_VK_GW_final.imr
  6. BEGIN SQL
  7. select T1."StockbookNumber" as c1,
  8. T1."Franchise" as c2,
  9. T1."ModelCode" as c3,
  10. T1."ModelVariant" as c4,
  11. T1."VehicleDescriptio001" as c5,
  12. T1."VehicleDescriptio002" as c6,
  13. T1."VehicleDescriptio003" as c7,
  14. T1."VehicleDescriptio004" as c8,
  15. T1."PhysicalBranch" as c9,
  16. T1."ACSStatus" as c10,
  17. T1."FullChassis" as c11,
  18. T1."RegistrationNumber" as c12,
  19. T1."RegDate" as c13,
  20. T1."CustomerName" as c14,
  21. T1."CustomerAddress001" as c15,
  22. T1."CustomerAddress002" as c16,
  23. T1."CustomerAddress003" as c17,
  24. T1."CustomerAddress004" as c18,
  25. T1."CustomerAddress005" as c19,
  26. T1."CustomerPostcode" as c20,
  27. T1."InvoiceName" as c21,
  28. T1."InvoiceAddress001" as c22,
  29. T1."InvoiceAddress002" as c23,
  30. T1."InvoiceAddress003" as c24,
  31. T1."InvoiceAddress004" as c25,
  32. T1."InvoiceAddress005" as c26,
  33. T1."InvAddrPostcode" as c27,
  34. T1."CustomerOrderNo" as c28,
  35. T1."OrderDate" as c29,
  36. T1."SOrderType" as c30,
  37. T1."SalesExecutive001" as c31,
  38. T1."DeliveryDate" as c32,
  39. T1."SalesInvoiceNumber" as c33,
  40. T1."InvoiceAccount" as c34,
  41. T1."CustomerAccount" as c35,
  42. T1."InvoiceTotal" as c36,
  43. T1."LatestProfitValue" as c37,
  44. T1."Cost" as c38,
  45. T1."MainInvoiceTotal" as c39,
  46. T1."OverallSaleNet" as c40,
  47. T2."VehicleType" as c41,
  48. T2."VehicleNumber" as c42,
  49. T2."InvoiceNumber" as c43,
  50. T2."InvoiceSequence" as c44,
  51. T2."InvoiceDate" as c45,
  52. T2."InvoiceValue" as c46,
  53. T3."FranchiseCode" as c47,
  54. T3."FullName001" as c48,
  55. T3."FullName002" as c49,
  56. T3."FullName003" as c50,
  57. T4."LocationCode" as c51,
  58. T4."Description" as c52,
  59. T4."LocationName" as c53,
  60. T5."UserID" as c54,
  61. T5."UserName" as c55,
  62. T6."OrderType" as c56,
  63. T6."Description001" as c57,
  64. T6."Description002" as c58,
  65. T6."Description003" as c59,
  66. T1."Client_DB" as c60,
  67. '' as c61,
  68. T4."LocationCode" as c62,
  69. T4."LocationCode" || ' - ' || T4."Description" as c63,
  70. T5."UserName" as c64,
  71. CASE WHEN (T1."Franchise" = 'M') THEN ('Mercedes PKW') WHEN (T1."Franchise" = 'T') THEN ('Mercedes TRAPO') WHEN (T1."Franchise" = 'Z') THEN ('Fremd') WHEN (T1."Franchise" = 'S') THEN ('Smart') WHEN (T1."Franchise" = 'F') THEN ('Fremd TRAPO') ELSE null END as c65,
  72. T7."Description002" as c66,
  73. T2."VehicleType" || (rtrim((cast_numberToString(cast_integer(T2."VehicleNumber"))))) || '/' || (od_right(T1."FullChassis",7)) || ' - ' || T5."UserName" || ' - ' || T1."CustomerName" as c67,
  74. T1."CustomerAccount" || ' - ' || T1."CustomerName" as c68,
  75. T8."VehicleMagicNumber" as c69,
  76. T8."VehicleType" as c70,
  77. CASE WHEN (T2."VehicleType" = 'U') THEN ('Gebrauchtwagen') ELSE ('Gebrauchtwagen') END as c71,
  78. CASE WHEN (((CASE WHEN (T2."VehicleType" = 'U') THEN ('Gebrauchtwagen') ELSE ('Gebrauchtwagen') END) = 'Neuwagen') and (T8."VehicleMagicNumber" IS NOT NULL)) THEN ('VFW GW') ELSE ('GW') END as c72,
  79. '' as c73,
  80. '' as c74,
  81. T6."OrderType" || ' - ' || T6."Description002" as c75,
  82. T2."VehicleType" || (rtrim((cast_numberToString(cast_integer(T2."VehicleNumber"))))) || '/' || (od_right(T1."FullChassis",7)) || ' - ' || T4."LocationCode" || ' - ' || (CASE WHEN (((CASE WHEN (T2."VehicleType" = 'U') THEN ('Gebrauchtwagen') ELSE ('Gebrauchtwagen') END) = 'Neuwagen') and (T8."VehicleMagicNumber" IS NOT NULL)) THEN ('VFW GW') ELSE ('GW') END) || ' - ' || T5."UserName" || ' - ' || T1."CustomerName" || ' - ' || (asciiz(extract(YEAR FROM T2."InvoiceDate"),4) || '-' || asciiz(extract(MONTH FROM T2."InvoiceDate"),2) || '-' || asciiz(extract(DAY FROM T2."InvoiceDate"),2)) as c76,
  83. (od_left(T1."CustomerPostcode",1)) as c77,
  84. (od_left(T1."CustomerPostcode",2)) as c78,
  85. (od_left(T1."CustomerPostcode",3)) as c79,
  86. (od_left(T1."CustomerPostcode",4)) as c80,
  87. T1."CustomerPostcode" as c81,
  88. T1."SupplierName" as c82,
  89. T1."VehicleDescriptio002" as c83,
  90. T1."BoughtBy" as c84,
  91. CASE WHEN (T1."LatestProfitValue" < 0) THEN ('DB1 < 0') ELSE ('DB1 > 0') END as c85,
  92. 1 as c86,
  93. T1."OverallSaleNet" - T1."OtherCosts012" as c87,
  94. (T1."OverallSaleNet" - T1."OtherCosts012") - T1."LatestProfitValue" as c88,
  95. 0 as c89,
  96. (T1."OverallSaleNet" - T1."OtherCosts012") - ((T1."OverallSaleNet" - T1."OtherCosts012") - T1."LatestProfitValue") as c90,
  97. T2."InvoiceDate" as c91,
  98. T1."InvoiceDate" as c92,
  99. (extract(DAY FROM T2."InvoiceDate" - T1."InvoiceDate")) as c93,
  100. T7."Description002" as c94,
  101. T1."OtherCosts012" as c95
  102. from ((((((("AUTOLINE"."import"."VS_UsedVehicleStock" T1 left outer join "AUTOLINE"."import"."VS_InvoiceStockFile" T2 on (T1."SalesInvoiceNumber" = T2."InvoiceNumber") and (T1."Client_DB" = T2."Client_DB")) left outer join "AUTOLINE"."import"."DD_FranchiseRecords" T3 on T1."Franchise" = T3."FranchiseCode") left outer join "AUTOLINE"."import"."GB_CompanyLocations" T4 on T1."SellingBranch" = T4."LocationCode") left outer join "AUTOLINE"."import"."GB_UserDetails" T5 on T1."SalesExecutive001" = T5."UserID") left outer join "AUTOLINE"."import"."VS_SalesOrderTypes" T6 on (T1."SOrderType" = T6."OrderType") and (T1."Client_DB" = T6."Client_DB")) left outer join "AUTOLINE"."import"."DD_ModelRecords" T7 on (T7."ShortFranchise" = T1."Franchise") and (T7."ModelCode" = T1."ModelCode")) left outer join "AUTOLINE"."import"."MK_DemonstrationVehicles" T8 on (T1."CRMVehicleMagic" = T8."VehicleMagicNumber") and (T8."Client_DB" <> '00'))
  103. where ((((((T1."SalesInvoiceNumber" IS NOT NULL) and (T1."SalesInvoiceNumber" <> 0)) and (T1."Client_DB" <> '00')) and (T1."InvoiceTotal" <> 0)) and (T2."InvoiceDate" >= TIMESTAMP '2018-01-01 00:00:00.000')) and (T1."Client_DB" = '10'))
  104. order by c42 asc
  105. END SQL
  106. COLUMN,0,Stockbooknumber
  107. COLUMN,1,Franchise
  108. COLUMN,2,Modelcode
  109. COLUMN,3,Modelvariant
  110. COLUMN,4,Vehicledescriptio001
  111. COLUMN,5,Vehicledescriptio002
  112. COLUMN,6,Vehicledescriptio003
  113. COLUMN,7,Vehicledescriptio004
  114. COLUMN,8,Physicalbranch
  115. COLUMN,9,Acsstatus
  116. COLUMN,10,Fullchassis
  117. COLUMN,11,Registrationnumber
  118. COLUMN,12,Regdate
  119. COLUMN,13,Customername
  120. COLUMN,14,Customeraddress001
  121. COLUMN,15,Customeraddress002
  122. COLUMN,16,Customeraddress003
  123. COLUMN,17,Customeraddress004
  124. COLUMN,18,Customeraddress005
  125. COLUMN,19,Customerpostcode
  126. COLUMN,20,Invoicename
  127. COLUMN,21,Invoiceaddress001
  128. COLUMN,22,Invoiceaddress002
  129. COLUMN,23,Invoiceaddress003
  130. COLUMN,24,Invoiceaddress004
  131. COLUMN,25,Invoiceaddress005
  132. COLUMN,26,Invaddrpostcode
  133. COLUMN,27,Customerorderno
  134. COLUMN,28,Orderdate
  135. COLUMN,29,Sordertype
  136. COLUMN,30,Salesexecutive001
  137. COLUMN,31,Deliverydate
  138. COLUMN,32,Salesinvoicenumber
  139. COLUMN,33,Invoiceaccount
  140. COLUMN,34,Customeraccount
  141. COLUMN,35,Invoicetotal
  142. COLUMN,36,Latestprofitvalue_DB1
  143. COLUMN,37,Cost_EW
  144. COLUMN,38,Maininvoicetotal
  145. COLUMN,39,Overallsalenet_Erlös_FZG
  146. COLUMN,40,Vehicletype
  147. COLUMN,41,Vehiclenumber
  148. COLUMN,42,Invoicenumber
  149. COLUMN,43,Invoicesequence
  150. COLUMN,44,Invoicedate
  151. COLUMN,45,Invoicevalue
  152. COLUMN,46,Franchisecode
  153. COLUMN,47,Fullname001
  154. COLUMN,48,Fullname002
  155. COLUMN,49,Fullname003
  156. COLUMN,50,Locationcode
  157. COLUMN,51,Description
  158. COLUMN,52,Locationname
  159. COLUMN,53,Userid
  160. COLUMN,54,Username
  161. COLUMN,55,Ordertype
  162. COLUMN,56,Description001
  163. COLUMN,57,Description002
  164. COLUMN,58,Description003
  165. COLUMN,59,Hauptbetrieb_ID
  166. COLUMN,60,Hauptbetrieb_Name
  167. COLUMN,61,Standort_ID
  168. COLUMN,62,Standort_Name
  169. COLUMN,63,Verkäufer
  170. COLUMN,64,Fabrikat
  171. COLUMN,65,Model
  172. COLUMN,66,FZG
  173. COLUMN,67,Kunde
  174. COLUMN,68,Vehiclemagicnumber_MK_Demo_Veh
  175. COLUMN,69,Vehicletype_MK_Demo_Veh
  176. COLUMN,70,Fahrzeugart
  177. COLUMN,71,Fahrzeugtyp
  178. COLUMN,72,Konto
  179. COLUMN,73,Fahrzeugtyp_1
  180. COLUMN,74,Kundenart
  181. COLUMN,75,FZG_Detail
  182. COLUMN,76,PLZ_1
  183. COLUMN,77,PLZ_2
  184. COLUMN,78,PLZ_3
  185. COLUMN,79,PLZ_4
  186. COLUMN,80,PLZ Code_Deb
  187. COLUMN,81,Name_Lieferant
  188. COLUMN,82,Modell_Beschreibung
  189. COLUMN,83,Name_Einkäufer
  190. COLUMN,84,DB1 < 0
  191. COLUMN,85,Menge
  192. COLUMN,86,Erlös_FZG
  193. COLUMN,87,Einsatz FZG
  194. COLUMN,88,Boni
  195. COLUMN,89,DB1_berechnet
  196. COLUMN,90,Invoice Date
  197. COLUMN,91,Invoicedate_VS_UsedVehicle
  198. COLUMN,92,Standtage
  199. COLUMN,93,Description002_Dd_Modelrecords
  200. COLUMN,94,Othercosts012