NW_GW_VK_Stk.iqd 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435
  1. COGNOS QUERY
  2. STRUCTURE,1,1
  3. DATABASE,O21
  4. DATASOURCENAME,C:\GAPS\Portal\System\IQD\NW\NW_GW_VK_Stk.imr
  5. TITLE,NW_GW_VK_Stk.imr
  6. BEGIN SQL
  7. select c1 as c1,
  8. c2 as c2,
  9. c3 as c3,
  10. c4 as c4,
  11. c5 as c5,
  12. c6 as c6,
  13. c7 as c7,
  14. c8 as c8,
  15. c9 as c9,
  16. c10 as c10,
  17. c11 as c11,
  18. c12 as c12,
  19. c13 as c13,
  20. c14 as c14,
  21. c15 as c15,
  22. c16 as c16,
  23. c17 as c17,
  24. c18 as c18,
  25. c19 as c19,
  26. c20 as c20,
  27. c21 as c21,
  28. c22 as c22,
  29. c23 as c23,
  30. c24 as c24,
  31. c25 as c25,
  32. c26 as c26,
  33. c27 as c27,
  34. c28 as c28,
  35. c29 as c29,
  36. c30 as c30,
  37. c31 as c31,
  38. c32 as c32,
  39. c33 as c33,
  40. c34 as c34,
  41. c35 as c35,
  42. c36 as c36,
  43. c37 as c37,
  44. c38 as c38,
  45. c39 as c39,
  46. c40 as c40,
  47. c41 as c41,
  48. c42 as c42,
  49. c43 as c43,
  50. c44 as c44,
  51. c45 as c45,
  52. c46 as c46,
  53. c47 as c47,
  54. c48 as c48,
  55. c49 as c49,
  56. c50 as c50,
  57. c51 as c51,
  58. c52 as c52,
  59. c53 as c53,
  60. c54 as c54,
  61. c55 as c55,
  62. c56 as c56,
  63. c57 as c57,
  64. c58 as c58,
  65. c59 as c59,
  66. c60 as c60,
  67. c61 as c61,
  68. c62 as c62,
  69. c63 as c63,
  70. c64 as c64,
  71. c65 as c65,
  72. c66 as c66,
  73. c67 as c67,
  74. c68 as c68,
  75. c69 as c69,
  76. c70 as c70,
  77. c71 as c71,
  78. c72 as c72,
  79. c73 as c73,
  80. c74 as c74,
  81. c75 as c75,
  82. c76 as c76,
  83. c77 as c77,
  84. c78 as c78,
  85. c79 as c79,
  86. c80 as c80,
  87. c81 as c81,
  88. c82 as c82,
  89. c83 as c83,
  90. c84 as c84,
  91. c85 as c85,
  92. c86 as c86,
  93. c87 as c87,
  94. c88 as c88,
  95. c89 as c89,
  96. c90 as c90,
  97. c91 as c91,
  98. c92 as c92,
  99. c93 as c93,
  100. c94 as c94,
  101. c95 as c95,
  102. c96 as c96,
  103. c97 as c97,
  104. c98 as c98,
  105. c99 as c99,
  106. c100 as c100,
  107. c101 as c101,
  108. c102 as c102,
  109. c103 as c103,
  110. c104 as c104,
  111. c105 as c105,
  112. XMAX(c105 for c1) as c106,
  113. c107 as c107,
  114. c108 as c108
  115. from
  116. (select c112 as c1,
  117. c205 as c2,
  118. c204 as c3,
  119. c203 as c4,
  120. c202 as c5,
  121. c201 as c6,
  122. c200 as c7,
  123. c199 as c8,
  124. c198 as c9,
  125. c197 as c10,
  126. c196 as c11,
  127. c195 as c12,
  128. c194 as c13,
  129. c193 as c14,
  130. c192 as c15,
  131. c191 as c16,
  132. c190 as c17,
  133. c189 as c18,
  134. c188 as c19,
  135. c187 as c20,
  136. c186 as c21,
  137. c136 as c22,
  138. c185 as c23,
  139. c184 as c24,
  140. c138 as c25,
  141. c183 as c26,
  142. c182 as c27,
  143. c181 as c28,
  144. c180 as c29,
  145. c179 as c30,
  146. c178 as c31,
  147. c177 as c32,
  148. c176 as c33,
  149. c175 as c34,
  150. c174 as c35,
  151. c173 as c36,
  152. c172 as c37,
  153. c171 as c38,
  154. c170 as c39,
  155. c169 as c40,
  156. c122 as c41,
  157. c168 as c42,
  158. c167 as c43,
  159. c166 as c44,
  160. c165 as c45,
  161. c164 as c46,
  162. c163 as c47,
  163. c162 as c48,
  164. c161 as c49,
  165. c160 as c50,
  166. c159 as c51,
  167. c158 as c52,
  168. c133 as c53,
  169. c157 as c54,
  170. c156 as c55,
  171. c155 as c56,
  172. c154 as c57,
  173. c153 as c58,
  174. c152 as c59,
  175. c120 as c60,
  176. c151 as c61,
  177. c150 as c62,
  178. c149 as c63,
  179. c134 as c64,
  180. c148 as c65,
  181. c147 as c66,
  182. c146 as c67,
  183. c145 as c68,
  184. c144 as c69,
  185. c143 as c70,
  186. c142 as c71,
  187. c141 as c72,
  188. c135 as c73,
  189. c140 as c74,
  190. c139 as c75,
  191. c138 as c76,
  192. '1' as c77,
  193. c137 as c78,
  194. c136 as c79,
  195. c135 as c80,
  196. c134 as c81,
  197. c120 as c82,
  198. c133 as c83,
  199. c132 as c84,
  200. c131 as c85,
  201. c130 as c86,
  202. c129 as c87,
  203. '' as c88,
  204. c128 as c89,
  205. c127 as c90,
  206. c126 as c91,
  207. c125 as c92,
  208. c124 as c93,
  209. c123 as c94,
  210. c123 as c95,
  211. c122 as c96,
  212. c121 as c97,
  213. c120 as c98,
  214. c119 as c99,
  215. 1 as c100,
  216. c118 as c101,
  217. c117 as c102,
  218. c113 as c103,
  219. c116 as c104,
  220. c115 as c105,
  221. c114 as c107,
  222. c113 as c108,
  223. XMAX(c115 for c112) as c109
  224. from
  225. (select T1."UNIT_NUMBER" as c112,
  226. (database()) as c113,
  227. (od_left(T12."DEPARTMENT",2)) as c114,
  228. T12."UNIQUE_IDENT" as c115,
  229. T12."DEPARTMENT" as c116,
  230. CASE WHEN (T10."DESCRIPTION" IN ('Chevrolet','Opel')) THEN (T10."DESCRIPTION") ELSE ('Fremdfabrikat') END as c117,
  231. CASE WHEN (T1."RECEPTION_DATE" IS NULL) THEN ((extract(DAY FROM T1."SALE_DATE" - T1."PURCH_DATE"))) ELSE ((extract(DAY FROM T1."SALE_DATE" - T1."RECEPTION_DATE"))) END as c118,
  232. T5."SEL_NAME" || ' / ' || (T6."CUSTOMER_NUMBER" || '- ' || T6."NAME") as c119,
  233. T8."MODEL_TEXT" as c120,
  234. CASE WHEN (T11."SEL_NAME" IS NULL) THEN (' - ' || ' / ' || T1."PREV_OWNER") ELSE (T11."SEL_NAME" || ' / ' || T1."PREV_OWNER") END as c121,
  235. T1."PREV_OWNER" as c122,
  236. T11."SEL_NAME" as c123,
  237. (T1."UNIT_NUMBER" || ' - ' || T8."CHASSIS_NUMBER") || ' - ' || T1."VEHICLE_TYPE" as c124,
  238. T1."UNIT_NUMBER" || ' - ' || T1."OWNER" || ' - ' || (asciiz(extract(YEAR FROM T8."ORIG_INV_DATE"),4) || '-' || asciiz(extract(MONTH FROM T8."ORIG_INV_DATE"),2) || '-' || asciiz(extract(DAY FROM T8."ORIG_INV_DATE"),2)) as c125,
  239. T1."UNIT_NUMBER" || ' - ' || T8."CHASSIS_NUMBER" as c126,
  240. CASE WHEN (T1."ECC_STATUS" = '21') THEN ('21 - Vorlauf') WHEN (T1."ECC_STATUS" = '25') THEN ('25 - für Kd best. FZG') WHEN (T1."ECC_STATUS" = '41') THEN ('41 - Bestand') WHEN (T1."ECC_STATUS" = '44') THEN ('44 - am Hof nicht fakt.') WHEN (T1."ECC_STATUS" = '64') THEN ('64 - verkauft') ELSE null END as c127,
  241. T8."COLOUR_CODE" || ' - ' || T8."COLOUR_CF" as c128,
  242. T6."CUSTOMER_GROUP" || ' - ' || T7."CUST_GROUP_SPECIFY" as c129,
  243. T6."CUSTOMER_NUMBER" || '- ' || T6."NAME" as c130,
  244. CASE WHEN (T2."VEHICLE_TYPE" IS NULL) THEN (T1."VEHICLE_TYPE") ELSE (T2."VEHICLE_TYPE" || ' - ' || T2."VEHICLE_TYPE_TEXT") END as c131,
  245. CASE WHEN (T2."VEHICLE_TYPE" IN ('K','M','N','T','V')) THEN ('Neuwagen') WHEN (T2."VEHICLE_TYPE" IN ('G','R','D')) THEN ('Gebrauchtwagen') ELSE null END as c132,
  246. T8."CHASSIS_NUMBER" as c133,
  247. T9."MOD_LIN_SPECIFY" as c134,
  248. T10."DESCRIPTION" as c135,
  249. T5."SEL_NAME" as c136,
  250. (od_left(T1."SALES_DEPARTMENT",2)) as c137,
  251. T1."SALE_DATE" as c138,
  252. T8."LATEST_INV_DATE" as c139,
  253. T8."ORIG_INV_DATE" as c140,
  254. T10."GLOBAL_MAKE_CD" as c141,
  255. T8."MAKE_CD" as c142,
  256. T8."MAKE" as c143,
  257. T8."COLOUR_CODE" as c144,
  258. T8."DRIVE_CODE" as c145,
  259. T8."MOTOR_CODE" as c146,
  260. T8."MILEAGE" as c147,
  261. T8."WORKSHOP_MODEL" as c148,
  262. T9."MODEL_LINE" as c149,
  263. T8."MODEL_LINE" as c150,
  264. T8."COLOUR_CF" as c151,
  265. T8."SALESMAN_SALE" as c152,
  266. T8."SALESMAN_BUY" as c153,
  267. T8."ARRIVAL_DATE" as c154,
  268. T8."LATEST_REG_DATE" as c155,
  269. T8."FIRST_REG_DATE" as c156,
  270. T8."OWNER_CODE" as c157,
  271. T8."REGISTER_NUMBER" as c158,
  272. T1."CONTRACT_DATE" as c159,
  273. T1."ORDER_CONFIRM_DATE" as c160,
  274. T1."ORDER_ARRIVAL_DATE" as c161,
  275. T7."CUST_GROUP_SPECIFY" as c162,
  276. T7."CUSTOMER_GROUP" as c163,
  277. T6."CUSTOMER_GROUP" as c164,
  278. T6."NAME" as c165,
  279. T6."CUSTOMER_NUMBER" as c166,
  280. T1."ACCOUNT_SALES" as c167,
  281. T1."ACCOUNT_PURCHASE" as c168,
  282. T1."OWNER" as c169,
  283. T1."LOCATION_CODE" as c170,
  284. T1."PA_NUMBER" as c171,
  285. T1."BUYING_ORDER_DATE" as c172,
  286. T1."BUYING_ORDER_NO" as c173,
  287. T1."STOCK_DAYS" as c174,
  288. T1."REG_FEE" as c175,
  289. T1."SALES_PRICE_UNIT" as c176,
  290. T1."COST_UNIT" as c177,
  291. T1."PURCH_PRICE_UNIT" as c178,
  292. T1."BUD_COST" as c179,
  293. T1."BUD_DEDUCT_FEE" as c180,
  294. T1."BUD_REG_FEE" as c181,
  295. T1."BUD_PURCH_PRICE" as c182,
  296. T1."BUD_SALE_DET" as c183,
  297. T1."SALE_INV_NUMBER" as c184,
  298. T5."SEL_FAMILY_NAME" as c185,
  299. T5."SELLER_CODE" as c186,
  300. T1."SALE_SALESMAN" as c187,
  301. T4."DESCRIPTION" as c188,
  302. T4."DEPARTMENT_TYPE_ID" as c189,
  303. T1."SALES_DEPARTMENT" as c190,
  304. T1."RECEPTION_DATE" as c191,
  305. T1."PURCH_DATE" as c192,
  306. T1."PURCH_SALSMAN_CODE" as c193,
  307. T1."PURCH_DEPARTMENT" as c194,
  308. T1."MILEAGE" as c195,
  309. T3."SPECIFY" as c196,
  310. T3."BOOK_KEEPING_CODE" as c197,
  311. T1."BOOK_KEEPING_CODE" as c198,
  312. T1."DEPRECIATION" as c199,
  313. T1."CAR_CREATION_DATE" as c200,
  314. T2."VEHICLE_TYPE_TEXT" as c201,
  315. T2."VEHICLE_TYPE" as c202,
  316. T1."VEHICLE_TYPE" as c203,
  317. T1."ECC_STATUS" as c204,
  318. T1."BASIS_NUMBER" as c205
  319. from ((((((((((("deop01"."dbo"."UNIT_FILE" T1 left outer join "deop01"."dbo"."vPP5R" T2 on T1."VEHICLE_TYPE" = T2."VEHICLE_TYPE") left outer join "deop01"."dbo"."vPP5M" T3 on T1."BOOK_KEEPING_CODE" = T3."BOOK_KEEPING_CODE") left outer join "deop01"."dbo"."DEPARTMENT_TYPE" T4 on T1."SALES_DEPARTMENT" = T4."DEPARTMENT_TYPE_ID") left outer join "deop01"."dbo"."vPP43" T5 on T1."SALE_SALESMAN" = T5."SELLER_CODE") left outer join "deop01"."dbo"."CUSTOMER" T6 on T1."ACCOUNT_SALES" = T6."CUSTOMER_NUMBER") left outer join "deop01"."dbo"."vPP48" T7 on T6."CUSTOMER_GROUP" = T7."CUSTOMER_GROUP") left outer join "deop01"."dbo"."VEHICLE" T8 on T1."BASIS_NUMBER" = T8."BASIS_NUMBER") left outer join "deop01"."dbo"."vPP5Q" T9 on (T8."MODEL_LINE" = T9."MODEL_LINE") and (T8."MAKE_CD" = T9."MAKE_CD")) left outer join "deop01"."dbo"."GLOBAL_MAKE" T10 on T8."MAKE_CD" = T10."GLOBAL_MAKE_CD") left outer join "deop01"."dbo"."vPP43" T11 on T1."PURCH_SALSMAN_CODE" = T11."SELLER_CODE") left outer join "deop01"."dbo"."UNIT_CHANGE_HIST" T12 on (T12."UNIT_NUMBER" = T1."UNIT_NUMBER") and (T12."DEPARTMENT" <> ' '))
  320. where ((T1."ECC_STATUS" = '64') and (T1."SALE_DATE" >= TIMESTAMP '2014-01-01 00:00:00.000'))
  321. ) D2
  322. ) D1
  323. where (c105 = c109)
  324. order by c1 asc
  325. END SQL
  326. COLUMN,0,Unit Number
  327. COLUMN,1,Basis Number
  328. COLUMN,2,Ecc Status
  329. COLUMN,3,Vehicle Type
  330. COLUMN,4,Vehicle Type_vpp5r
  331. COLUMN,5,Vehicle Type Text_vpp5r
  332. COLUMN,6,Car Creation Date
  333. COLUMN,7,Depreciation
  334. COLUMN,8,Book Keeping Code
  335. COLUMN,9,Book Keeping Code_vpp5m
  336. COLUMN,10,Specify_vpp5m
  337. COLUMN,11,Mileage
  338. COLUMN,12,Purch Department
  339. COLUMN,13,Purch Salsman Code
  340. COLUMN,14,Purch Date
  341. COLUMN,15,Reception Date
  342. COLUMN,16,Sales Department
  343. COLUMN,17,Department Type Id_Dep
  344. COLUMN,18,Description_Dep
  345. COLUMN,19,Sale Salesman
  346. COLUMN,20,Seller Code_vpp43
  347. COLUMN,21,Sel Name_vpp43
  348. COLUMN,22,Sel Family Name_vpp43
  349. COLUMN,23,Sale Inv Number
  350. COLUMN,24,Sale Date
  351. COLUMN,25,Bud Sale Det
  352. COLUMN,26,Bud Purch Price
  353. COLUMN,27,Bud Reg Fee
  354. COLUMN,28,Bud Deduct Fee
  355. COLUMN,29,Bud Cost
  356. COLUMN,30,Purch Price Unit
  357. COLUMN,31,Cost Unit
  358. COLUMN,32,Sales Price Unit
  359. COLUMN,33,Reg Fee
  360. COLUMN,34,Stock Days
  361. COLUMN,35,Buying Order No
  362. COLUMN,36,Buying Order Date
  363. COLUMN,37,Pa Number
  364. COLUMN,38,Location Code
  365. COLUMN,39,Owner
  366. COLUMN,40,Prev Owner
  367. COLUMN,41,Account Purchase
  368. COLUMN,42,Account Sales
  369. COLUMN,43,Customer Number_Cust
  370. COLUMN,44,Name_Cust
  371. COLUMN,45,Customer Group_Cust
  372. COLUMN,46,Customer Group_vpp48
  373. COLUMN,47,Cust Group Specify_vpp48
  374. COLUMN,48,Order Arrival Date
  375. COLUMN,49,Order Confirm Date
  376. COLUMN,50,Contract Date
  377. COLUMN,51,Register Number
  378. COLUMN,52,Chassis Number
  379. COLUMN,53,Owner Code
  380. COLUMN,54,First Reg Date
  381. COLUMN,55,Latest Reg Date
  382. COLUMN,56,Arrival Date
  383. COLUMN,57,Salesman Buy
  384. COLUMN,58,Salesman Sale
  385. COLUMN,59,Model Text
  386. COLUMN,60,Colour Cf
  387. COLUMN,61,Model Line
  388. COLUMN,62,Model Line_vpp5q
  389. COLUMN,63,Mod Lin Specify_vpp5q
  390. COLUMN,64,Workshop Model
  391. COLUMN,65,Mileage
  392. COLUMN,66,Motor Code
  393. COLUMN,67,Drive Code
  394. COLUMN,68,Colour Code
  395. COLUMN,69,Make
  396. COLUMN,70,Make Cd
  397. COLUMN,71,Global Make Cd
  398. COLUMN,72,Description_Global_Make
  399. COLUMN,73,Orig Inv Date
  400. COLUMN,74,Latest Inv Date
  401. COLUMN,75,Invoice Date
  402. COLUMN,76,Hauptbetrieb
  403. COLUMN,77,Standort_Verkaufskostenstelle
  404. COLUMN,78,Verkäufer
  405. COLUMN,79,Fabrikat_ori
  406. COLUMN,80,Model
  407. COLUMN,81,Modellbez
  408. COLUMN,82,Fahrgestellnr
  409. COLUMN,83,Fahrzeugart
  410. COLUMN,84,Fahrzeugtyp
  411. COLUMN,85,Kunde
  412. COLUMN,86,Kundenart
  413. COLUMN,87,Geschäftsart
  414. COLUMN,88,Farbe
  415. COLUMN,89,ECC_Status_Text
  416. COLUMN,90,FZG
  417. COLUMN,91,FZG_1
  418. COLUMN,92,FZG_Liste_1
  419. COLUMN,93,Sel Name_EK_vpp43
  420. COLUMN,94,Einkäufer
  421. COLUMN,95,Vorbesitzer
  422. COLUMN,96,FZG_Liste_2
  423. COLUMN,97,FZG_Liste_3
  424. COLUMN,98,FZG_Liste_4
  425. COLUMN,99,Menge
  426. COLUMN,100,Standtage
  427. COLUMN,101,Fabrikat
  428. COLUMN,102,Mandant
  429. COLUMN,103,Department_unit_change_hist
  430. COLUMN,104,Unique Ident_unit_change_hist
  431. COLUMN,105,Maximun_Unique_Ident
  432. COLUMN,106,Standort
  433. COLUMN,107,Mandant