NW_GW_Bestand_NW.iqd 8.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232
  1. COGNOS QUERY
  2. STRUCTURE,1,1
  3. DATABASE,GC_AUTOLINE
  4. DATASOURCENAME,C:\GlobalCube\System\Autoline\IQD\nw\NW_GW_Bestand_NW.imr
  5. TITLE,NW_GW_Bestand_NW.imr
  6. BEGIN SQL
  7. select T1."StockbookNumber" as c1,
  8. T1."Franchise" as c2,
  9. T1."ModelCode" as c3,
  10. T1."ACSStatus" as c4,
  11. T1."VariantCode" as c5,
  12. T1."VehicleDescriptio001" as c6,
  13. T1."VehicleDescriptio002" as c7,
  14. T1."VehicleDescriptio003" as c8,
  15. T1."VehicleDescriptio004" as c9,
  16. T1."PhysicalBranch" 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."CusAddressPostcode" 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."InvAddressPostcode" as c27,
  34. T1."CustomerOrderNo" as c28,
  35. T1."OrderDate" as c29,
  36. T1."SOrderType" as c30,
  37. T1."SalesExecutive001" as c31,
  38. T1."InvoiceAccount" as c32,
  39. T1."CustomerAccount" as c33,
  40. T1."InvoiceTotal" as c34,
  41. T1."LatestProfitValue" as c35,
  42. T1."Cost" as c36,
  43. T1."MainInvoiceTotal" as c37,
  44. T1."ConsignmentTotal" as c38,
  45. T1."OverallSaleNet" as c39,
  46. T1."RecovOptionPrice015" as c40,
  47. T1."SupplierName" as c41,
  48. T1."Client_DB" as c42,
  49. T2."VehicleType" as c43,
  50. T2."VehicleNumber" as c44,
  51. T2."InvoiceNumber" as c45,
  52. T2."InvoiceSequence" as c46,
  53. T2."InvoiceDate" as c47,
  54. T2."InvoiceValue" as c48,
  55. T3."FranchiseCode" as c49,
  56. T3."FullName001" as c50,
  57. T3."FullName002" as c51,
  58. T3."FullName003" as c52,
  59. T4."LocationCode" as c53,
  60. T4."Description" as c54,
  61. T4."LocationName" as c55,
  62. T5."UserID" as c56,
  63. T5."UserName" as c57,
  64. T6."OrderType" as c58,
  65. T6."Description001" as c59,
  66. T6."Description002" as c60,
  67. T6."Description003" as c61,
  68. T1."Client_DB" as c62,
  69. '' as c63,
  70. T4."LocationCode" as c64,
  71. T4."LocationCode" || ' - ' || T4."Description" as c65,
  72. T5."UserName" as c66,
  73. T3."FullName002" as c67,
  74. (od_left((ucase(T1."VehicleDescriptio002")),4)) as c68,
  75. CASE WHEN (T1."FullChassis" IS NOT NULL) THEN ((rtrim((cast_numberToString(cast_integer(T1."StockbookNumber"))))) || '/' || T1."FullChassis" || ' - ' || (CASE WHEN (((('Neuwagen')) = 'Neuwagen') and (T7."VehicleMagicNumber" IS NOT NULL)) THEN ('VFW NW') ELSE ('NW') END)) ELSE ((rtrim((cast_numberToString(cast_integer(T1."StockbookNumber"))))) || ' - ' || (CASE WHEN (((('Neuwagen')) = 'Neuwagen') and (T7."VehicleMagicNumber" IS NOT NULL)) THEN ('VFW NW') ELSE ('NW') END)) END as c69,
  76. T1."CustomerAccount" || ' - ' || T1."CustomerName" as c70,
  77. T7."VehicleMagicNumber" as c71,
  78. T7."VehicleType" as c72,
  79. ('Neuwagen') as c73,
  80. CASE WHEN (((('Neuwagen')) = 'Neuwagen') and (T7."VehicleMagicNumber" IS NOT NULL)) THEN ('VFW NW') ELSE ('NW') END as c74,
  81. '' as c75,
  82. '' as c76,
  83. T6."OrderType" || ' - ' || T6."Description002" as c77,
  84. T2."VehicleType" || (rtrim((cast_numberToString(cast_integer(T2."VehicleNumber"))))) || '/' || (od_right(T1."FullChassis",7)) || ' - ' || T4."LocationCode" || ' - ' || (CASE WHEN (((('Neuwagen')) = 'Neuwagen') and (T7."VehicleMagicNumber" IS NOT NULL)) THEN ('VFW NW') ELSE ('NW') 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 c78,
  85. (od_left(T1."CusAddressPostcode",1)) as c79,
  86. (od_left(T1."CusAddressPostcode",2)) as c80,
  87. (od_left(T1."CusAddressPostcode",3)) as c81,
  88. (od_left(T1."CusAddressPostcode",4)) as c82,
  89. T1."CusAddressPostcode" as c83,
  90. T1."SupplierName" as c84,
  91. T1."VehicleDescriptio002" as c85,
  92. '' as c86,
  93. CASE WHEN (T1."LatestProfitValue" < 0) THEN ('DB1 < 0') ELSE ('DB1 > 0') END as c87,
  94. 1 as c88,
  95. T1."OverallSaleNet" as c89,
  96. T1."OverallSaleNet" - T1."LatestProfitValue" as c90,
  97. T1."RecovOptionPrice015" as c91,
  98. T1."OverallSaleNet" - (T1."OverallSaleNet" - T1."LatestProfitValue") as c92,
  99. (@CURRENT_DATE) as c93,
  100. T1."ConsignmentDate" as c94,
  101. T1."EstimDeliveryDate" as c95,
  102. T1."EstimDateReceived" as c96,
  103. (extract(DAY FROM (now()) - T1."ConsignmentDate")) as c97,
  104. CASE WHEN (((extract(DAY FROM (now()) - T1."ConsignmentDate"))) BETWEEN 0 AND 30) THEN ('0 - 30 Tage') WHEN (((extract(DAY FROM (now()) - T1."ConsignmentDate"))) BETWEEN 31 AND 60) THEN ('31 - 60 Tage') WHEN (((extract(DAY FROM (now()) - T1."ConsignmentDate"))) BETWEEN 61 AND 90) THEN ('61 - 90 Tage') WHEN (((extract(DAY FROM (now()) - T1."ConsignmentDate"))) BETWEEN 91 AND 180) THEN ('91 - 180 Tage') WHEN (((extract(DAY FROM (now()) - T1."ConsignmentDate"))) BETWEEN 181 AND 360) THEN ('181 - 360 Tage') WHEN (((extract(DAY FROM (now()) - T1."ConsignmentDate"))) > 360) THEN ('> 360 Tage') ELSE null END as c98,
  105. T1."ColourWheelbaseDesc" as c99,
  106. T1."ColourWheelbaseDesc" as c100,
  107. T1."PhysicalBranch" as c101,
  108. T1."SupplierName" as c102,
  109. T1."SupplierName" as c103,
  110. '' as c104,
  111. '' as c105,
  112. '' as c106,
  113. '' as c107,
  114. '' as c108,
  115. '' as c109,
  116. T1."Cost" as c110
  117. from (((((("AUTOLINE"."import"."VS_NewVehicleStock" 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"."MK_DemonstrationVehicles" T7 on (T1."CRMVehicleMagic" = T7."VehicleMagicNumber") and (T7."Client_DB" <> '00'))
  118. where (((((T1."SalesInvoiceNumber" IS NULL) or (T1."SalesInvoiceNumber" = 0)) or (T1."InvoiceTotal" = 0)) and (T1."Client_DB" <> '00')) and (T1."ConsignmentDate" IS NOT NULL))
  119. order by c1 asc
  120. END SQL
  121. COLUMN,0,Stockbooknumber
  122. COLUMN,1,Franchise
  123. COLUMN,2,Modelcode
  124. COLUMN,3,Acsstatus
  125. COLUMN,4,Variantcode
  126. COLUMN,5,Vehicledescriptio001
  127. COLUMN,6,Vehicledescriptio002
  128. COLUMN,7,Vehicledescriptio003
  129. COLUMN,8,Vehicledescriptio004
  130. COLUMN,9,Physicalbranch
  131. COLUMN,10,Fullchassis
  132. COLUMN,11,Registrationnumber
  133. COLUMN,12,Regdate
  134. COLUMN,13,Customername
  135. COLUMN,14,Customeraddress001
  136. COLUMN,15,Customeraddress002
  137. COLUMN,16,Customeraddress003
  138. COLUMN,17,Customeraddress004
  139. COLUMN,18,Customeraddress005
  140. COLUMN,19,Cusaddresspostcode
  141. COLUMN,20,Invoicename
  142. COLUMN,21,Invoiceaddress001
  143. COLUMN,22,Invoiceaddress002
  144. COLUMN,23,Invoiceaddress003
  145. COLUMN,24,Invoiceaddress004
  146. COLUMN,25,Invoiceaddress005
  147. COLUMN,26,Invaddresspostcode
  148. COLUMN,27,Customerorderno
  149. COLUMN,28,Orderdate
  150. COLUMN,29,Sordertype
  151. COLUMN,30,Salesexecutive001
  152. COLUMN,31,Invoiceaccount
  153. COLUMN,32,Customeraccount
  154. COLUMN,33,Invoicetotal
  155. COLUMN,34,Latestprofitvalue_DB1
  156. COLUMN,35,Cost_EW
  157. COLUMN,36,Maininvoicetotal
  158. COLUMN,37,Consignmenttotal
  159. COLUMN,38,Overallsalenet_Erlös_FZG
  160. COLUMN,39,Recovoptionprice015_VK-Hilfe
  161. COLUMN,40,Suppliername
  162. COLUMN,41,Client Db
  163. COLUMN,42,Vehicletype
  164. COLUMN,43,Vehiclenumber
  165. COLUMN,44,Invoicenumber
  166. COLUMN,45,Invoicesequence
  167. COLUMN,46,Invoicedate
  168. COLUMN,47,Invoicevalue
  169. COLUMN,48,Franchisecode
  170. COLUMN,49,Fullname001
  171. COLUMN,50,Fullname002
  172. COLUMN,51,Fullname003
  173. COLUMN,52,Locationcode
  174. COLUMN,53,Description
  175. COLUMN,54,Locationname
  176. COLUMN,55,Userid
  177. COLUMN,56,Username
  178. COLUMN,57,Ordertype
  179. COLUMN,58,Description001
  180. COLUMN,59,Description002
  181. COLUMN,60,Description003
  182. COLUMN,61,Hauptbetrieb_ID
  183. COLUMN,62,Hauptbetrieb_Name
  184. COLUMN,63,Standort_ID
  185. COLUMN,64,Standort_Name
  186. COLUMN,65,Verkäufer
  187. COLUMN,66,Fabrikat
  188. COLUMN,67,Model
  189. COLUMN,68,FZG
  190. COLUMN,69,Kunde
  191. COLUMN,70,Vehiclemagicnumber_MK_Demo_Veh
  192. COLUMN,71,Vehicletype_MK_Demo_Veh
  193. COLUMN,72,Fahrzeugart
  194. COLUMN,73,Fahrzeugtyp
  195. COLUMN,74,Konto
  196. COLUMN,75,Fahrzeugtyp_1
  197. COLUMN,76,Kundenart
  198. COLUMN,77,FZG_Detail
  199. COLUMN,78,PLZ_1
  200. COLUMN,79,PLZ_2
  201. COLUMN,80,PLZ_3
  202. COLUMN,81,PLZ_4
  203. COLUMN,82,PLZ Code_Deb
  204. COLUMN,83,Name_Lieferant
  205. COLUMN,84,Modell_Beschreibung
  206. COLUMN,85,Name_Einkäufer
  207. COLUMN,86,DB1 < 0
  208. COLUMN,87,Menge
  209. COLUMN,88,Erlös_FZG
  210. COLUMN,89,Einsatz FZG
  211. COLUMN,90,Boni
  212. COLUMN,91,DB1_berechnet
  213. COLUMN,92,Invoice Date
  214. COLUMN,93,Consignmentdate
  215. COLUMN,94,Estimdeliverydate
  216. COLUMN,95,Estimdatereceived
  217. COLUMN,96,Standtage
  218. COLUMN,97,Standtagestaffel
  219. COLUMN,98,Colourwheelbasedesc
  220. COLUMN,99,Farbe
  221. COLUMN,100,Standort_1
  222. COLUMN,101,Suppliername
  223. COLUMN,102,Name_Lieferant
  224. COLUMN,103,Lieferant/Einkäufer
  225. COLUMN,104,Einkäufer
  226. COLUMN,105,FZG_Einkäufer
  227. COLUMN,106,EZ
  228. COLUMN,107,Km-stand
  229. COLUMN,108,Bestandsart
  230. COLUMN,109,Einsatz