COGNOS QUERY
STRUCTURE,1,1
DATABASE,O21
DATASOURCENAME,C:\GAPS\Portal\System\IQD\NW\NW_BE.imr
TITLE,NW_BE.imr
BEGIN SQL
select c1 as c1,
	   c2 as c2,
	   c3 as c3,
	   c4 as c4,
	   c5 as c5,
	   c6 as c6,
	   c7 as c7,
	   c8 as c8,
	   c9 as c9,
	   c10 as c10,
	   c11 as c11,
	   c12 as c12,
	   c13 as c13,
	   c14 as c14,
	   c15 as c15,
	   c16 as c16,
	   c17 as c17,
	   c18 as c18,
	   c19 as c19,
	   c20 as c20,
	   c21 as c21,
	   c22 as c22,
	   c23 as c23,
	   c24 as c24,
	   c25 as c25,
	   c26 as c26,
	   c27 as c27,
	   c28 as c28,
	   c29 as c29,
	   c30 as c30,
	   c31 as c31,
	   c32 as c32,
	   c33 as c33,
	   c34 as c34,
	   c35 as c35,
	   c36 as c36,
	   c37 as c37,
	   c38 as c38,
	   c39 as c39,
	   c40 as c40,
	   c41 as c41,
	   c42 as c42,
	   c43 as c43,
	   c44 as c44,
	   c45 as c45,
	   c46 as c46,
	   c47 as c47,
	   c48 as c48,
	   c49 as c49,
	   c50 as c50,
	   c51 as c51,
	   c52 as c52,
	   c53 as c53,
	   c54 as c54,
	   c55 as c55,
	   c56 as c56,
	   c57 as c57,
	   c58 as c58,
	   c59 as c59,
	   c60 as c60,
	   c61 as c61,
	   c62 as c62,
	   c63 as c63,
	   c64 as c64,
	   c65 as c65,
	   c66 as c66,
	   c67 as c67,
	   c68 as c68,
	   c69 as c69,
	   c70 as c70,
	   c71 as c71,
	   c72 as c72,
	   c73 as c73,
	   c74 as c74,
	   c75 as c75,
	   c76 as c76,
	   c77 as c77,
	   c78 as c78,
	   c79 as c79,
	   c80 as c80,
	   c81 as c81,
	   c82 as c82,
	   c83 as c83,
	   c84 as c84,
	   c85 as c85,
	   c86 as c86,
	   c87 as c87,
	   c88 as c88,
	   c89 as c89,
	   c90 as c90,
	   c91 as c91,
	   c92 as c92,
	   c93 as c93,
	   c94 as c94,
	   c95 as c95,
	   c96 as c96,
	   c97 as c97,
	   c98 as c98,
	   c99 as c99,
	   c100 as c100,
	   c101 as c101,
	   c102 as c102,
	   c103 as c103,
	   c104 as c104,
	   c105 as c105,
	   c106 as c106,
	   c107 as c107,
	   c108 as c108,
	   c109 as c109,
	   c110 as c110,
	   c111 as c111,
	   c112 as c112,
	   c113 as c113,
	   c114 as c114,
	   c115 as c115,
	   c116 as c116,
	   c117 as c117,
	   c118 as c118,
	   c119 as c119,
	   c120 as c120,
	   c121 as c121,
	   c122 as c122,
	   c123 as c123,
	   c124 as c124,
	   c125 as c125,
	   c126 as c126,
	   c127 as c127,
	   c128 as c128,
	   c129 as c129,
	   c130 as c130,
	   c131 as c131,
	   c132 as c132,
	   c133 as c133,
	   c134 as c134,
	   c135 as c135,
	   c136 as c136,
	   c137 as c137,
	   c138 as c138,
	   c139 as c139,
	   c140 as c140,
	   c141 as c141,
	   c142 as c142,
	   c143 as c143,
	   c144 as c144,
	   c145 as c145,
	   c146 as c146,
	   c147 as c147,
	   c148 as c148,
	   c149 as c149,
	   c150 as c150,
	   c151 as c151,
	   c152 as c152,
	   c153 as c153,
	   c154 as c154,
	   c155 as c155,
	   c156 as c156,
	   c157 as c157,
	   c158 as c158,
	   c159 as c159,
	   c160 as c160,
	   c161 as c161,
	   c162 as c162,
	   c163 as c163,
	   c164 as c164,
	   c165 as c165,
	   c166 as c166,
	   c167 as c167,
	   c168 as c168,
	   c169 as c169,
	   c170 as c170,
	   c171 as c171,
	   c172 as c172,
	   c173 as c173,
	   c174 as c174,
	   c175 as c175,
	   c176 as c176,
	   c177 as c177,
	   c178 as c178,
	   c179 as c179,
	   c180 as c180,
	   c181 as c181,
	   c182 as c182,
	   c183 as c183,
	   c184 as c184,
	   c185 as c185,
	   c186 as c186,
	   c187 as c187,
	   c188 as c188,
	   c189 as c189,
	   c190 as c190,
	   c191 as c191,
	   c192 as c192,
	   c193 as c193,
	   c194 as c194,
	   c195 as c195,
	   c196 as c196,
	   c197 as c197,
	   c198 as c198,
	   c199 as c199,
	   c200 as c200,
	   c201 as c201,
	   c202 as c202,
	   c203 as c203,
	   c204 as c204,
	   c205 as c205,
	   c206 as c206,
	   c207 as c207,
	   c208 as c208,
	   c209 as c209,
	   c210 as c210,
	   c211 as c211,
	   c212 as c212,
	   c213 as c213,
	   c214 as c214,
	   c215 as c215,
	   c216 as c216,
	   c217 as c217,
	   c218 as c218,
	   c219 as c219,
	   c220 as c220,
	   c221 as c221,
	   c222 as c222,
	   c223 as c223,
	   c224 as c224,
	   c225 as c225,
	   c226 as c226,
	   c227 as c227,
	   c228 as c228,
	   c229 as c229,
	   c230 as c230,
	   c231 as c231,
	   c232 as c232,
	   c233 as c233,
	   c234 as c234,
	   XMAX(c234 for c1) as c235
from 
(select c239 as c1,
	   c461 as c2,
	   c460 as c3,
	   c459 as c4,
	   c458 as c5,
	   c457 as c6,
	   c456 as c7,
	   c455 as c8,
	   c454 as c9,
	   c453 as c10,
	   c452 as c11,
	   c451 as c12,
	   c450 as c13,
	   c449 as c14,
	   c448 as c15,
	   c447 as c16,
	   c446 as c17,
	   c445 as c18,
	   c444 as c19,
	   c443 as c20,
	   c442 as c21,
	   c441 as c22,
	   c440 as c23,
	   c439 as c24,
	   c438 as c25,
	   c437 as c26,
	   c436 as c27,
	   c435 as c28,
	   c434 as c29,
	   c433 as c30,
	   c432 as c31,
	   c431 as c32,
	   c430 as c33,
	   c243 as c34,
	   c429 as c35,
	   c428 as c36,
	   c427 as c37,
	   c245 as c38,
	   c426 as c39,
	   c425 as c40,
	   c424 as c41,
	   c244 as c42,
	   c423 as c43,
	   c422 as c44,
	   c421 as c45,
	   c420 as c46,
	   c419 as c47,
	   c418 as c48,
	   c417 as c49,
	   c416 as c50,
	   c415 as c51,
	   c414 as c52,
	   c413 as c53,
	   c412 as c54,
	   c411 as c55,
	   c410 as c56,
	   c409 as c57,
	   c408 as c58,
	   c407 as c59,
	   c406 as c60,
	   c405 as c61,
	   c404 as c62,
	   c403 as c63,
	   c402 as c64,
	   c401 as c65,
	   c400 as c66,
	   c399 as c67,
	   c398 as c68,
	   c248 as c69,
	   c397 as c70,
	   c396 as c71,
	   c395 as c72,
	   c394 as c73,
	   c393 as c74,
	   c392 as c75,
	   c391 as c76,
	   c390 as c77,
	   c389 as c78,
	   c388 as c79,
	   c387 as c80,
	   c386 as c81,
	   c385 as c82,
	   c384 as c83,
	   c383 as c84,
	   c382 as c85,
	   c381 as c86,
	   c380 as c87,
	   c379 as c88,
	   c378 as c89,
	   c377 as c90,
	   c376 as c91,
	   c375 as c92,
	   c374 as c93,
	   c373 as c94,
	   c372 as c95,
	   c371 as c96,
	   c370 as c97,
	   c369 as c98,
	   c368 as c99,
	   c367 as c100,
	   c366 as c101,
	   c365 as c102,
	   c364 as c103,
	   c363 as c104,
	   c362 as c105,
	   c361 as c106,
	   c360 as c107,
	   c359 as c108,
	   c358 as c109,
	   c357 as c110,
	   c356 as c111,
	   c355 as c112,
	   c354 as c113,
	   c353 as c114,
	   c352 as c115,
	   c261 as c116,
	   c351 as c117,
	   c350 as c118,
	   c349 as c119,
	   c348 as c120,
	   c347 as c121,
	   c346 as c122,
	   c345 as c123,
	   c344 as c124,
	   c343 as c125,
	   c342 as c126,
	   c262 as c127,
	   c341 as c128,
	   c340 as c129,
	   c339 as c130,
	   c338 as c131,
	   c337 as c132,
	   c336 as c133,
	   c335 as c134,
	   c334 as c135,
	   c333 as c136,
	   c332 as c137,
	   c331 as c138,
	   c330 as c139,
	   c329 as c140,
	   c328 as c141,
	   c327 as c142,
	   c326 as c143,
	   c325 as c144,
	   c324 as c145,
	   c323 as c146,
	   c322 as c147,
	   c321 as c148,
	   c320 as c149,
	   c319 as c150,
	   c318 as c151,
	   c317 as c152,
	   c316 as c153,
	   c315 as c154,
	   c314 as c155,
	   c313 as c156,
	   c312 as c157,
	   c311 as c158,
	   c310 as c159,
	   c309 as c160,
	   c308 as c161,
	   c307 as c162,
	   c306 as c163,
	   c305 as c164,
	   c304 as c165,
	   c303 as c166,
	   c302 as c167,
	   c301 as c168,
	   c300 as c169,
	   c299 as c170,
	   c298 as c171,
	   c297 as c172,
	   c296 as c173,
	   c295 as c174,
	   c294 as c175,
	   c293 as c176,
	   c292 as c177,
	   c291 as c178,
	   c290 as c179,
	   c289 as c180,
	   c288 as c181,
	   c287 as c182,
	   c286 as c183,
	   c285 as c184,
	   c284 as c185,
	   c283 as c186,
	   c282 as c187,
	   c281 as c188,
	   c280 as c189,
	   c279 as c190,
	   c278 as c191,
	   c277 as c192,
	   c276 as c193,
	   c263 as c194,
	   c275 as c195,
	   c274 as c196,
	   c273 as c197,
	   c272 as c198,
	   c271 as c199,
	   c270 as c200,
	   c269 as c201,
	   c268 as c202,
	   '1' as c203,
	   c267 as c204,
	   c266 as c205,
	   c265 as c206,
	   c264 as c207,
	   c256 as c208,
	   c263 as c209,
	   c262 as c210,
	   c261 as c211,
	   c260 as c212,
	   c259 as c213,
	   c258 as c214,
	   c257 as c215,
	   c256 as c216,
	   c255 as c217,
	   1 as c218,
	   c254 as c219,
	   c253 as c220,
	   c252 as c221,
	   c251 as c222,
	   c250 as c223,
	   c249 as c224,
	   c248 as c225,
	   c247 as c226,
	   c246 as c227,
	   c246 as c228,
	   c245 as c229,
	   c244 as c230,
	   c243 as c231,
	   c242 as c232,
	   c241 as c233,
	   c240 as c234,
	   XMAX(c240 for c239) as c236
from 
(select T1."UNIT_NUMBER" as c239,
	   T9."UNIQUE_IDENT" as c240,
	   T9."DEPARTMENT" as c241,
	   CASE WHEN (T7."DESCRIPTION" IN ('Opel','Volvo')) THEN (T7."DESCRIPTION") ELSE ('Fremdfabrikat') END as c242,
	   T1."BUD_SALE_DET" as c243,
	   T1."COST_UNIT" as c244,
	   T1."BUD_COST" as c245,
	   T8."SEL_NAME" as c246,
	   T8."SELLER_CODE" as c247,
	   (T1."LOCATION_CODE") as c248,
	   (CASE WHEN (T1."ECC_STATUS" IN ('21','24')) THEN (0) WHEN (T1."RECEPTION_DATE" IS NULL) THEN ((extract(DAY FROM ((now())) - T1."PURCH_DATE"))) ELSE ((extract(DAY FROM ((now())) - T1."RECEPTION_DATE"))) END) * 15 as c249,
	   CASE WHEN (T3."CAR_LETTER" = 'Konsi') THEN ('Konsi-FZG') ELSE ('Lagerfahrzeug') END as c250,
	   T3."CAR_LETTER" as c251,
	   CASE WHEN ((CASE WHEN (T1."ECC_STATUS" IN ('21','24')) THEN (0) WHEN (T1."RECEPTION_DATE" IS NULL) THEN ((extract(DAY FROM ((now())) - T1."PURCH_DATE"))) ELSE ((extract(DAY FROM ((now())) - T1."RECEPTION_DATE"))) END) BETWEEN 0 AND 30) THEN ('0 - 30 Tage') WHEN ((CASE WHEN (T1."ECC_STATUS" IN ('21','24')) THEN (0) WHEN (T1."RECEPTION_DATE" IS NULL) THEN ((extract(DAY FROM ((now())) - T1."PURCH_DATE"))) ELSE ((extract(DAY FROM ((now())) - T1."RECEPTION_DATE"))) END) BETWEEN 31 AND 60) THEN ('31 - 60 Tage') WHEN ((CASE WHEN (T1."ECC_STATUS" IN ('21','24')) THEN (0) WHEN (T1."RECEPTION_DATE" IS NULL) THEN ((extract(DAY FROM ((now())) - T1."PURCH_DATE"))) ELSE ((extract(DAY FROM ((now())) - T1."RECEPTION_DATE"))) END) BETWEEN 61 AND 90) THEN ('61 - 90 Tage') WHEN ((CASE WHEN (T1."ECC_STATUS" IN ('21','24')) THEN (0) WHEN (T1."RECEPTION_DATE" IS NULL) THEN ((extract(DAY FROM ((now())) - T1."PURCH_DATE"))) ELSE ((extract(DAY FROM ((now())) - T1."RECEPTION_DATE"))) END) BETWEEN 91 AND 180) THEN ('91 - 180 Tage') WHEN ((CASE WHEN (T1."ECC_STATUS" IN ('21','24')) THEN (0) WHEN (T1."RECEPTION_DATE" IS NULL) THEN ((extract(DAY FROM ((now())) - T1."PURCH_DATE"))) ELSE ((extract(DAY FROM ((now())) - T1."RECEPTION_DATE"))) END) > 180) THEN ('> 180 Tage') ELSE null END as c252,
	   CASE WHEN (T1."ECC_STATUS" IN ('21','24')) THEN (0) WHEN (T1."RECEPTION_DATE" IS NULL) THEN ((extract(DAY FROM ((now())) - T1."PURCH_DATE"))) ELSE ((extract(DAY FROM ((now())) - T1."RECEPTION_DATE"))) END as c253,
	   (now()) as c254,
	   T1."PURCH_PRICE_UNIT" + T1."COST_UNIT" as c255,
	   T7."DESCRIPTION" as c256,
	   T7."GLOBAL_MAKE_CD" as c257,
	   CASE WHEN (T2."VEHICLE_TYPE" IS NULL) THEN (T1."VEHICLE_TYPE") ELSE (T2."VEHICLE_TYPE" || ' - ' || T2."VEHICLE_TYPE_TEXT") END as c258,
	   T1."UNIT_NUMBER" || ' - ' || T3."CHASSIS_NUMBER" as c259,
	   T3."COLOUR_CODE" || ' - ' || T3."COLOUR_CF" as c260,
	   T3."CHASSIS_NUMBER" as c261,
	   T3."MODEL_TEXT" as c262,
	   T4."MOD_LIN_SPECIFY" as c263,
	   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 c264,
	   T6."DESCRIPTION" as c265,
	   T6."DEPARTMENT_TYPE_ID" as c266,
	   (od_left(T6."DEPARTMENT_TYPE_ID",2)) as c267,
	   T5."MAKE_CODE" as c268,
	   T5."MODEL_GROUP" as c269,
	   T5."MODEL_TYPE" as c270,
	   T5."ORIG_MODEL_CODE" as c271,
	   T5."MODEL_TEXT" as c272,
	   T5."MAKE_CD" as c273,
	   T5."WORKSHOP_MODEL" as c274,
	   T4."MAKE_CD" as c275,
	   T4."MODEL_LINE" as c276,
	   T3."MAKE_CD" as c277,
	   T3."SOLDMARK_DATE" as c278,
	   T3."DISCOUNT_PERC_WORK" as c279,
	   T3."WORKSHOP_PRICECODE" as c280,
	   T3."HOURLY_REPAIR_RATE" as c281,
	   T3."SERVICE_DAYS" as c282,
	   T3."FUELTYPE" as c283,
	   T3."DEALER_MARKING" as c284,
	   T3."DEALER_NUMBER" as c285,
	   T3."PURCH_AMOUNT" as c286,
	   T3."LATEST_INV_DATE" as c287,
	   T3."PAID_DATE" as c288,
	   T3."HOUR_RATE_TABLE" as c289,
	   T3."MAKE" as c290,
	   T3."MODEL_TYPE_2" as c291,
	   T3."MODEL_LINE_GROUP" as c292,
	   T3."PURCH_CAL_DATE" as c293,
	   T3."STOCK_DATE" as c294,
	   T3."CAL_COST_DATE" as c295,
	   T3."CAL_COST" as c296,
	   T3."AVAILABLE" as c297,
	   T3."TYPE_YEAR" as c298,
	   T3."ASU_INSP" as c299,
	   T3."ASU_DATE" as c300,
	   T3."ASU_TYPE" as c301,
	   T3."TUV_INSP" as c302,
	   T3."TUV_DATE" as c303,
	   T3."TUV_TYPE" as c304,
	   T3."NO_OF_OWNERS" as c305,
	   T3."TRIM_CODE" as c306,
	   T3."COLOUR_CODE" as c307,
	   T3."DRIVE_CODE" as c308,
	   T3."GEAR_CODE" as c309,
	   T3."MOTOR_CODE" as c310,
	   T3."MISC_10_CF" as c311,
	   T3."MISC_9_CF" as c312,
	   T3."MISC_8_CF" as c313,
	   T3."MISC_7_CF" as c314,
	   T3."MISC_6_CF" as c315,
	   T3."MISC_5_CF" as c316,
	   T3."MISC_4_CF" as c317,
	   T3."MISC_3_CF" as c318,
	   T3."MISC_2_CF" as c319,
	   T3."MISC_1_CF" as c320,
	   T3."MILEAGE" as c321,
	   T3."EQUIPMENT_4" as c322,
	   T3."EQUIPMENT_3" as c323,
	   T3."EQUIPMENT_2" as c324,
	   T3."EQUIPMENT_1" as c325,
	   T3."DECLARATION_NUMBER" as c326,
	   T3."DECLARATION_PLACE" as c327,
	   T3."DECLARATION_DATE" as c328,
	   T3."SEATS" as c329,
	   T3."CYLINDER_VOLUME" as c330,
	   T3."YEAR_MODEL_CF" as c331,
	   T3."KEY_CODE" as c332,
	   T3."MOTOR_NUMBER" as c333,
	   T3."CLASSIFICATION" as c334,
	   T3."FAC_MODEL_CODE_S" as c335,
	   T3."WORKSHOP_MODEL" as c336,
	   T3."MODEL_LINE" as c337,
	   T3."TRIM_TXT" as c338,
	   T3."COLOUR_CF" as c339,
	   T3."ORIG_MODEL_CODE2" as c340,
	   T3."ORIG_MODEL_CODE1" as c341,
	   T3."SALESMAN_SALE" as c342,
	   T3."SALESMAN_BUY" as c343,
	   T3."ARRIVAL_DATE" as c344,
	   T3."EXPECTED_ARR_DATE" as c345,
	   T3."FIRST_OCCUR_DATE" as c346,
	   T3."LATEST_REG_DATE" as c347,
	   T3."FIRST_REG_DATE" as c348,
	   T3."FAC_MODEL_CODE_L" as c349,
	   T3."CAR_STATUS" as c350,
	   T3."CAR_GROUP" as c351,
	   T3."REGISTER_NUMBER" as c352,
	   T3."HANDLER" as c353,
	   T3."TRANSACT_DATE" as c354,
	   T3."BASIS_NUMBER" as c355,
	   CASE WHEN (T1."ECC_STATUS" = '21') THEN ('21 - Lagerauftrag') WHEN (T1."ECC_STATUS" = '24') THEN ('24 - Kundenauftrag') WHEN (T1."ECC_STATUS" = '41') THEN ('41 - Bestand') WHEN (T1."ECC_STATUS" = '44') THEN ('44 - auf Lager verkauft') WHEN (T1."ECC_STATUS" = '64') THEN ('64 - verkauft') WHEN (T1."ECC_STATUS" = '42') THEN ('42') ELSE null END as c356,
	   T2."VEHICLE_TYPE_TEXT" as c357,
	   T2."VEHICLE_TYPE" as c358,
	   T1."UNIQUE_IDENT" as c359,
	   T1."PRICE_LIST_DATE" as c360,
	   T1."PRICE_LIST_VERSION" as c361,
	   T1."PURCH_ORIGIN_CODE" as c362,
	   T1."SALE_PRICE_DATE" as c363,
	   T1."BUD_OPT_PRICE" as c364,
	   T1."RECEPTION_DATE" as c365,
	   T1."EST_REFERENCE_NO" as c366,
	   T1."EST_SALES_PRICE" as c367,
	   T1."FORD_INT_DATE" as c368,
	   T1."VALUATION_DATE" as c369,
	   T1."DESIRED_DELIV_DATE" as c370,
	   T1."BOOKING_DEALER_NR" as c371,
	   T1."DEALER_MARKING" as c372,
	   T1."EXP_ARRIVAL_TIME" as c373,
	   T1."CONTRACT_DATE" as c374,
	   T1."CNTRACT_DUE_DATE" as c375,
	   T1."TRANSFER_VAT_RC" as c376,
	   T1."VAT_RATE_CODE" as c377,
	   T1."VAT_TABLE_NORMAL" as c378,
	   T1."VAT_TABLE_WORK" as c379,
	   T1."PRICE_LABEL_DATE" as c380,
	   T1."ORDER_CONFIRM_DATE" as c381,
	   T1."ORDER_ARRIVAL_DATE" as c382,
	   T1."TRF_DEPARTMENT" as c383,
	   T1."UNIT_SOLD" as c384,
	   T1."SALE_ORDER_NO" as c385,
	   T1."TRF_TAXBASIS_PURCH" as c386,
	   T1."TRF_TAXBASIS_SALES" as c387,
	   T1."FREIGHT_BALANCE" as c388,
	   T1."RESERVATION_TEXT" as c389,
	   T1."RESERVATION_PERSON" as c390,
	   T1."RESERVATION_DATE" as c391,
	   T1."DELIVERY_DATE_VEH" as c392,
	   T1."COMMISION_NO" as c393,
	   T1."RECALC_CODE" as c394,
	   T1."BUDG_PRICE_VAT" as c395,
	   T1."ACCOUNT_SALES" as c396,
	   T1."ACCOUNT_PURCHASE" as c397,
	   T1."INVOICE_PERMISSION" as c398,
	   T1."LATEST_UPDATE" as c399,
	   T1."VEHICLE_UPDATE" as c400,
	   T1."PA_NUMBER" as c401,
	   T1."BUYING_ORDER_DATE" as c402,
	   T1."BUYING_ORDER_NO" as c403,
	   T1."CONDITION_UNIT" as c404,
	   T1."TRANSFER_BBDB" as c405,
	   T1."DELETE_PROPOSAL" as c406,
	   T1."STOCK_DAYS" as c407,
	   T1."TRANSFER_DATE" as c408,
	   T1."OR_MARK" as c409,
	   T1."COST_TAX" as c410,
	   T1."PURCH_TAX" as c411,
	   T1."TRANSFER_SOLD" as c412,
	   T1."TRANSFER_TAX_PCT" as c413,
	   T1."TRANSFER_TAX_BASIS" as c414,
	   T1."TRANSFER_ACC_CODE" as c415,
	   T1."TRANSFER_TAX_HAND" as c416,
	   T1."TRANSFER_LINE" as c417,
	   T1."NEXT_LINE_1" as c418,
	   T1."NEXT_LINE_UNIT" as c419,
	   T1."INTEREST_2" as c420,
	   T1."INTEREST_1" as c421,
	   T1."REG_FEE" as c422,
	   T1."SALES_PRICE_UNIT" as c423,
	   T1."PURCH_PRICE_UNIT" as c424,
	   T1."OWNER" as c425,
	   T1."PREV_OWNER" as c426,
	   T1."BUD_DEDUCT_FEE" as c427,
	   T1."BUD_REG_FEE" as c428,
	   T1."BUD_PURCH_PRICE" as c429,
	   T1."UNIT_IN_CHANGE" as c430,
	   T1."SCRAP_CODE" as c431,
	   T1."SALE_DATE" as c432,
	   T1."SALE_INV_NUMBER" as c433,
	   T1."SALE_SALESMAN" as c434,
	   T1."SALES_DEPARTMENT" as c435,
	   T1."PURCH_DATE" as c436,
	   T1."PURCH_INVNO" as c437,
	   T1."PURCH_SALSMAN_CODE" as c438,
	   T1."PURCH_DEPARTMENT" as c439,
	   T1."MILEAGE" as c440,
	   T1."INTEREST_CODE" as c441,
	   T1."TAX_HANDLING" as c442,
	   T1."BOOK_KEEPING_CODE" as c443,
	   T1."TRANSFER_TAX" as c444,
	   T1."DEPRECIATION" as c445,
	   T1."UNIT_LAST_UPD_DTE" as c446,
	   T1."TAX_CODE" as c447,
	   T1."INTERNAL_CODE" as c448,
	   T1."DISCOUNT_LIMIT" as c449,
	   T1."DISCOUNT_PERC_WORK" as c450,
	   T1."PRICE_CODE" as c451,
	   T1."DELIVERY_STOP_CODE" as c452,
	   T1."SMALL_INV_CHARGE" as c453,
	   T1."SMALL_ACCESSORIES" as c454,
	   T1."PMT_TERM" as c455,
	   T1."CAR_CREATION_DATE" as c456,
	   T1."HANDLER" as c457,
	   T1."TRANSACT_DATE" as c458,
	   T1."VEHICLE_TYPE" as c459,
	   T1."ECC_STATUS" as c460,
	   T1."BASIS_NUMBER" as c461
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"."VEHICLE" T3 on T1."BASIS_NUMBER" = T3."BASIS_NUMBER") left outer join "deop01"."dbo"."vPP5Q" T4 on (T3."MODEL_LINE" = T4."MODEL_LINE") and (T3."MAKE_CD" = T4."MAKE_CD")) left outer join "deop01"."dbo"."vPP74" T5 on (T3."WORKSHOP_MODEL" = T5."WORKSHOP_MODEL") and (T3."MAKE_CD" = T5."MAKE_CD")) left outer join "deop01"."dbo"."DEPARTMENT_TYPE" T6 on T1."PURCH_DEPARTMENT" = T6."DEPARTMENT_TYPE_ID") left outer join "deop01"."dbo"."GLOBAL_MAKE" T7 on T3."MAKE_CD" = T7."GLOBAL_MAKE_CD") left outer join "deop01"."dbo"."vPP43" T8 on T1."PURCH_SALSMAN_CODE" = T8."SELLER_CODE") left outer join "deop01"."dbo"."UNIT_CHANGE_HIST" T9 on (T9."UNIT_NUMBER" = T1."UNIT_NUMBER") and (T9."DEPARTMENT" <> ' '))
where (T1."ECC_STATUS" IN ('21','24','25','41','42','44'))
) D2
) D1
where ((c236 = c234) or (c234 IS NULL))
order by c1 asc,c220 desc

END SQL
COLUMN,0,Unit Number
COLUMN,1,Basis Number
COLUMN,2,Ecc Status
COLUMN,3,Vehicle Type
COLUMN,4,Transact Date
COLUMN,5,Handler
COLUMN,6,Car Creation Date
COLUMN,7,Pmt Term
COLUMN,8,Small Accessories
COLUMN,9,Small Inv Charge
COLUMN,10,Delivery Stop Code
COLUMN,11,Price Code
COLUMN,12,Discount Perc Work
COLUMN,13,Discount Limit
COLUMN,14,Internal Code
COLUMN,15,Tax Code
COLUMN,16,Unit Last Upd Dte
COLUMN,17,Depreciation
COLUMN,18,Transfer Tax
COLUMN,19,Book Keeping Code
COLUMN,20,Tax Handling
COLUMN,21,Interest Code
COLUMN,22,Mileage
COLUMN,23,Purch Department
COLUMN,24,Purch Salsman Code
COLUMN,25,Purch Invno
COLUMN,26,Purch Date
COLUMN,27,Sales Department
COLUMN,28,Sale Salesman
COLUMN,29,Sale Inv Number
COLUMN,30,Sale Date
COLUMN,31,Scrap Code
COLUMN,32,Unit In Change
COLUMN,33,Bud Sale Det
COLUMN,34,Bud Purch Price
COLUMN,35,Bud Reg Fee
COLUMN,36,Bud Deduct Fee
COLUMN,37,Bud Cost
COLUMN,38,Prev Owner
COLUMN,39,Owner
COLUMN,40,Purch Price Unit
COLUMN,41,Cost Unit
COLUMN,42,Sales Price Unit
COLUMN,43,Reg Fee
COLUMN,44,Interest 1
COLUMN,45,Interest 2
COLUMN,46,Next Line Unit
COLUMN,47,Next Line 1
COLUMN,48,Transfer Line
COLUMN,49,Transfer Tax Hand
COLUMN,50,Transfer Acc Code
COLUMN,51,Transfer Tax Basis
COLUMN,52,Transfer Tax Pct
COLUMN,53,Transfer Sold
COLUMN,54,Purch Tax
COLUMN,55,Cost Tax
COLUMN,56,Or Mark
COLUMN,57,Transfer Date
COLUMN,58,Stock Days
COLUMN,59,Delete Proposal
COLUMN,60,Transfer Bbdb
COLUMN,61,Condition Unit
COLUMN,62,Buying Order No
COLUMN,63,Buying Order Date
COLUMN,64,Pa Number
COLUMN,65,Vehicle Update
COLUMN,66,Latest Update
COLUMN,67,Invoice Permission
COLUMN,68,Location Code
COLUMN,69,Account Purchase
COLUMN,70,Account Sales
COLUMN,71,Budg Price Vat
COLUMN,72,Recalc Code
COLUMN,73,Commision No
COLUMN,74,Delivery Date Veh
COLUMN,75,Reservation Date
COLUMN,76,Reservation Person
COLUMN,77,Reservation Text
COLUMN,78,Freight Balance
COLUMN,79,Trf Taxbasis Sales
COLUMN,80,Trf Taxbasis Purch
COLUMN,81,Sale Order No
COLUMN,82,Unit Sold
COLUMN,83,Trf Department
COLUMN,84,Order Arrival Date
COLUMN,85,Order Confirm Date
COLUMN,86,Price Label Date
COLUMN,87,Vat Table Work
COLUMN,88,Vat Table Normal
COLUMN,89,Vat Rate Code
COLUMN,90,Transfer Vat Rc
COLUMN,91,Cntract Due Date
COLUMN,92,Contract Date
COLUMN,93,Exp Arrival Time
COLUMN,94,Dealer Marking
COLUMN,95,Booking Dealer Nr
COLUMN,96,Desired Deliv Date
COLUMN,97,Valuation Date
COLUMN,98,Ford Int Date
COLUMN,99,Est Sales Price
COLUMN,100,Est Reference No
COLUMN,101,Reception Date
COLUMN,102,Bud Opt Price
COLUMN,103,Sale Price Date
COLUMN,104,Purch Origin Code
COLUMN,105,Price List Version
COLUMN,106,Price List Date
COLUMN,107,Unique Ident
COLUMN,108,Vehicle Type vpp5r
COLUMN,109,Vehicle Type Text
COLUMN,110,ECC_Status_Text
COLUMN,111,Basis Number
COLUMN,112,Transact Date
COLUMN,113,Handler
COLUMN,114,Register Number
COLUMN,115,Chassis Number
COLUMN,116,Car Group
COLUMN,117,Car Status
COLUMN,118,Fac Model Code L
COLUMN,119,First Reg Date
COLUMN,120,Latest Reg Date
COLUMN,121,First Occur Date
COLUMN,122,Expected Arr Date
COLUMN,123,Arrival Date
COLUMN,124,Salesman Buy
COLUMN,125,Salesman Sale
COLUMN,126,Model Text
COLUMN,127,Orig Model Code1
COLUMN,128,Orig Model Code2
COLUMN,129,Colour Cf
COLUMN,130,Trim Txt
COLUMN,131,Model Line
COLUMN,132,Workshop Model
COLUMN,133,Fac Model Code S
COLUMN,134,Classification
COLUMN,135,Motor Number
COLUMN,136,Key Code
COLUMN,137,Year Model Cf
COLUMN,138,Cylinder Volume
COLUMN,139,Seats
COLUMN,140,Declaration Date
COLUMN,141,Declaration Place
COLUMN,142,Declaration Number
COLUMN,143,Equipment 1
COLUMN,144,Equipment 2
COLUMN,145,Equipment 3
COLUMN,146,Equipment 4
COLUMN,147,Mileage
COLUMN,148,Misc 1 Cf
COLUMN,149,Misc 2 Cf
COLUMN,150,Misc 3 Cf
COLUMN,151,Misc 4 Cf
COLUMN,152,Misc 5 Cf
COLUMN,153,Misc 6 Cf
COLUMN,154,Misc 7 Cf
COLUMN,155,Misc 8 Cf
COLUMN,156,Misc 9 Cf
COLUMN,157,Misc 10 Cf
COLUMN,158,Motor Code
COLUMN,159,Gear Code
COLUMN,160,Drive Code
COLUMN,161,Colour Code
COLUMN,162,Trim Code
COLUMN,163,No Of Owners
COLUMN,164,Tuv Type
COLUMN,165,Tuv Date
COLUMN,166,Tuv Insp
COLUMN,167,Asu Type
COLUMN,168,Asu Date
COLUMN,169,Asu Insp
COLUMN,170,Type Year
COLUMN,171,Available
COLUMN,172,Cal Cost
COLUMN,173,Cal Cost Date
COLUMN,174,Stock Date
COLUMN,175,Purch Cal Date
COLUMN,176,Model Line Group
COLUMN,177,Model Type 2
COLUMN,178,Make
COLUMN,179,Hour Rate Table
COLUMN,180,Paid Date
COLUMN,181,Latest Inv Date
COLUMN,182,Purch Amount
COLUMN,183,Dealer Number
COLUMN,184,Dealer Marking
COLUMN,185,Fueltype
COLUMN,186,Service Days
COLUMN,187,Hourly Repair Rate
COLUMN,188,Workshop Pricecode
COLUMN,189,Discount Perc Work
COLUMN,190,Soldmark Date
COLUMN,191,Make Cd
COLUMN,192,Model Line
COLUMN,193,Mod Lin Specify
COLUMN,194,Make Cd
COLUMN,195,Workshop Model
COLUMN,196,Make Cd
COLUMN,197,Model Text
COLUMN,198,Orig Model Code
COLUMN,199,Model Type
COLUMN,200,Model Group
COLUMN,201,Make Code
COLUMN,202,Hauptbetrieb
COLUMN,203,Standort
COLUMN,204,Department Type Id
COLUMN,205,Description
COLUMN,206,Fahrzeugart
COLUMN,207,Fabrikat_ori
COLUMN,208,Model
COLUMN,209,Modellbez
COLUMN,210,Fahrgestellnr
COLUMN,211,Farbe
COLUMN,212,FZG
COLUMN,213,Fahrzeugtyp
COLUMN,214,Global Make Cd
COLUMN,215,Description
COLUMN,216,Einsatz
COLUMN,217,Menge
COLUMN,218,Heute
COLUMN,219,Standtage
COLUMN,220,Standtagestaffel
COLUMN,221,Car Letter
COLUMN,222,Fahrzeugart_Konsi
COLUMN,223,kalk_Kosten
COLUMN,224,Betrieb
COLUMN,225,Seller Code
COLUMN,226,Sel Name
COLUMN,227,VB_Einkauf
COLUMN,228,geplante Kosten
COLUMN,229,tatsächl. Kosten
COLUMN,230,geplanter VK
COLUMN,231,Fabrikat
COLUMN,232,Department_unique_change_history
COLUMN,233,Unique Ident_unique_change_history
COLUMN,234,MAXIMUM  (  Unique Ident_unique_change_history  )

