123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435 |
- COGNOS QUERY
- STRUCTURE,1,1
- DATABASE,O21
- DATASOURCENAME,C:\GAPS\Portal\System\IQD\NW\NW_GW_VK_Stk.imr
- TITLE,NW_GW_VK_Stk.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,
- XMAX(c105 for c1) as c106,
- c107 as c107,
- c108 as c108
- from
- (select c112 as c1,
- c205 as c2,
- c204 as c3,
- c203 as c4,
- c202 as c5,
- c201 as c6,
- c200 as c7,
- c199 as c8,
- c198 as c9,
- c197 as c10,
- c196 as c11,
- c195 as c12,
- c194 as c13,
- c193 as c14,
- c192 as c15,
- c191 as c16,
- c190 as c17,
- c189 as c18,
- c188 as c19,
- c187 as c20,
- c186 as c21,
- c136 as c22,
- c185 as c23,
- c184 as c24,
- c138 as c25,
- c183 as c26,
- c182 as c27,
- c181 as c28,
- c180 as c29,
- c179 as c30,
- c178 as c31,
- c177 as c32,
- c176 as c33,
- c175 as c34,
- c174 as c35,
- c173 as c36,
- c172 as c37,
- c171 as c38,
- c170 as c39,
- c169 as c40,
- c122 as c41,
- c168 as c42,
- c167 as c43,
- c166 as c44,
- c165 as c45,
- c164 as c46,
- c163 as c47,
- c162 as c48,
- c161 as c49,
- c160 as c50,
- c159 as c51,
- c158 as c52,
- c133 as c53,
- c157 as c54,
- c156 as c55,
- c155 as c56,
- c154 as c57,
- c153 as c58,
- c152 as c59,
- c120 as c60,
- c151 as c61,
- c150 as c62,
- c149 as c63,
- c134 as c64,
- c148 as c65,
- c147 as c66,
- c146 as c67,
- c145 as c68,
- c144 as c69,
- c143 as c70,
- c142 as c71,
- c141 as c72,
- c135 as c73,
- c140 as c74,
- c139 as c75,
- c138 as c76,
- '1' as c77,
- c137 as c78,
- c136 as c79,
- c135 as c80,
- c134 as c81,
- c120 as c82,
- c133 as c83,
- c132 as c84,
- c131 as c85,
- c130 as c86,
- c129 as c87,
- '' as c88,
- c128 as c89,
- c127 as c90,
- c126 as c91,
- c125 as c92,
- c124 as c93,
- c123 as c94,
- c123 as c95,
- c122 as c96,
- c121 as c97,
- c120 as c98,
- c119 as c99,
- 1 as c100,
- c118 as c101,
- c117 as c102,
- c113 as c103,
- c116 as c104,
- c115 as c105,
- c114 as c107,
- c113 as c108,
- XMAX(c115 for c112) as c109
- from
- (select T1."UNIT_NUMBER" as c112,
- (database()) as c113,
- (od_left(T12."DEPARTMENT",2)) as c114,
- T12."UNIQUE_IDENT" as c115,
- T12."DEPARTMENT" as c116,
- CASE WHEN (T10."DESCRIPTION" IN ('Chevrolet','Opel')) THEN (T10."DESCRIPTION") ELSE ('Fremdfabrikat') END as c117,
- 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,
- T5."SEL_NAME" || ' / ' || (T6."CUSTOMER_NUMBER" || '- ' || T6."NAME") as c119,
- T8."MODEL_TEXT" as c120,
- CASE WHEN (T11."SEL_NAME" IS NULL) THEN (' - ' || ' / ' || T1."PREV_OWNER") ELSE (T11."SEL_NAME" || ' / ' || T1."PREV_OWNER") END as c121,
- T1."PREV_OWNER" as c122,
- T11."SEL_NAME" as c123,
- (T1."UNIT_NUMBER" || ' - ' || T8."CHASSIS_NUMBER") || ' - ' || T1."VEHICLE_TYPE" as c124,
- 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,
- T1."UNIT_NUMBER" || ' - ' || T8."CHASSIS_NUMBER" as c126,
- 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,
- T8."COLOUR_CODE" || ' - ' || T8."COLOUR_CF" as c128,
- T6."CUSTOMER_GROUP" || ' - ' || T7."CUST_GROUP_SPECIFY" as c129,
- T6."CUSTOMER_NUMBER" || '- ' || T6."NAME" as c130,
- CASE WHEN (T2."VEHICLE_TYPE" IS NULL) THEN (T1."VEHICLE_TYPE") ELSE (T2."VEHICLE_TYPE" || ' - ' || T2."VEHICLE_TYPE_TEXT") END as c131,
- 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,
- T8."CHASSIS_NUMBER" as c133,
- T9."MOD_LIN_SPECIFY" as c134,
- T10."DESCRIPTION" as c135,
- T5."SEL_NAME" as c136,
- (od_left(T1."SALES_DEPARTMENT",2)) as c137,
- T1."SALE_DATE" as c138,
- T8."LATEST_INV_DATE" as c139,
- T8."ORIG_INV_DATE" as c140,
- T10."GLOBAL_MAKE_CD" as c141,
- T8."MAKE_CD" as c142,
- T8."MAKE" as c143,
- T8."COLOUR_CODE" as c144,
- T8."DRIVE_CODE" as c145,
- T8."MOTOR_CODE" as c146,
- T8."MILEAGE" as c147,
- T8."WORKSHOP_MODEL" as c148,
- T9."MODEL_LINE" as c149,
- T8."MODEL_LINE" as c150,
- T8."COLOUR_CF" as c151,
- T8."SALESMAN_SALE" as c152,
- T8."SALESMAN_BUY" as c153,
- T8."ARRIVAL_DATE" as c154,
- T8."LATEST_REG_DATE" as c155,
- T8."FIRST_REG_DATE" as c156,
- T8."OWNER_CODE" as c157,
- T8."REGISTER_NUMBER" as c158,
- T1."CONTRACT_DATE" as c159,
- T1."ORDER_CONFIRM_DATE" as c160,
- T1."ORDER_ARRIVAL_DATE" as c161,
- T7."CUST_GROUP_SPECIFY" as c162,
- T7."CUSTOMER_GROUP" as c163,
- T6."CUSTOMER_GROUP" as c164,
- T6."NAME" as c165,
- T6."CUSTOMER_NUMBER" as c166,
- T1."ACCOUNT_SALES" as c167,
- T1."ACCOUNT_PURCHASE" as c168,
- T1."OWNER" as c169,
- T1."LOCATION_CODE" as c170,
- T1."PA_NUMBER" as c171,
- T1."BUYING_ORDER_DATE" as c172,
- T1."BUYING_ORDER_NO" as c173,
- T1."STOCK_DAYS" as c174,
- T1."REG_FEE" as c175,
- T1."SALES_PRICE_UNIT" as c176,
- T1."COST_UNIT" as c177,
- T1."PURCH_PRICE_UNIT" as c178,
- T1."BUD_COST" as c179,
- T1."BUD_DEDUCT_FEE" as c180,
- T1."BUD_REG_FEE" as c181,
- T1."BUD_PURCH_PRICE" as c182,
- T1."BUD_SALE_DET" as c183,
- T1."SALE_INV_NUMBER" as c184,
- T5."SEL_FAMILY_NAME" as c185,
- T5."SELLER_CODE" as c186,
- T1."SALE_SALESMAN" as c187,
- T4."DESCRIPTION" as c188,
- T4."DEPARTMENT_TYPE_ID" as c189,
- T1."SALES_DEPARTMENT" as c190,
- T1."RECEPTION_DATE" as c191,
- T1."PURCH_DATE" as c192,
- T1."PURCH_SALSMAN_CODE" as c193,
- T1."PURCH_DEPARTMENT" as c194,
- T1."MILEAGE" as c195,
- T3."SPECIFY" as c196,
- T3."BOOK_KEEPING_CODE" as c197,
- T1."BOOK_KEEPING_CODE" as c198,
- T1."DEPRECIATION" as c199,
- T1."CAR_CREATION_DATE" as c200,
- T2."VEHICLE_TYPE_TEXT" as c201,
- T2."VEHICLE_TYPE" as c202,
- T1."VEHICLE_TYPE" as c203,
- T1."ECC_STATUS" as c204,
- T1."BASIS_NUMBER" as c205
- 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" <> ' '))
- where ((T1."ECC_STATUS" = '64') and (T1."SALE_DATE" >= TIMESTAMP '2014-01-01 00:00:00.000'))
- ) D2
- ) D1
- where (c105 = c109)
- order by c1 asc
- END SQL
- COLUMN,0,Unit Number
- COLUMN,1,Basis Number
- COLUMN,2,Ecc Status
- COLUMN,3,Vehicle Type
- COLUMN,4,Vehicle Type_vpp5r
- COLUMN,5,Vehicle Type Text_vpp5r
- COLUMN,6,Car Creation Date
- COLUMN,7,Depreciation
- COLUMN,8,Book Keeping Code
- COLUMN,9,Book Keeping Code_vpp5m
- COLUMN,10,Specify_vpp5m
- COLUMN,11,Mileage
- COLUMN,12,Purch Department
- COLUMN,13,Purch Salsman Code
- COLUMN,14,Purch Date
- COLUMN,15,Reception Date
- COLUMN,16,Sales Department
- COLUMN,17,Department Type Id_Dep
- COLUMN,18,Description_Dep
- COLUMN,19,Sale Salesman
- COLUMN,20,Seller Code_vpp43
- COLUMN,21,Sel Name_vpp43
- COLUMN,22,Sel Family Name_vpp43
- COLUMN,23,Sale Inv Number
- COLUMN,24,Sale Date
- COLUMN,25,Bud Sale Det
- COLUMN,26,Bud Purch Price
- COLUMN,27,Bud Reg Fee
- COLUMN,28,Bud Deduct Fee
- COLUMN,29,Bud Cost
- COLUMN,30,Purch Price Unit
- COLUMN,31,Cost Unit
- COLUMN,32,Sales Price Unit
- COLUMN,33,Reg Fee
- COLUMN,34,Stock Days
- COLUMN,35,Buying Order No
- COLUMN,36,Buying Order Date
- COLUMN,37,Pa Number
- COLUMN,38,Location Code
- COLUMN,39,Owner
- COLUMN,40,Prev Owner
- COLUMN,41,Account Purchase
- COLUMN,42,Account Sales
- COLUMN,43,Customer Number_Cust
- COLUMN,44,Name_Cust
- COLUMN,45,Customer Group_Cust
- COLUMN,46,Customer Group_vpp48
- COLUMN,47,Cust Group Specify_vpp48
- COLUMN,48,Order Arrival Date
- COLUMN,49,Order Confirm Date
- COLUMN,50,Contract Date
- COLUMN,51,Register Number
- COLUMN,52,Chassis Number
- COLUMN,53,Owner Code
- COLUMN,54,First Reg Date
- COLUMN,55,Latest Reg Date
- COLUMN,56,Arrival Date
- COLUMN,57,Salesman Buy
- COLUMN,58,Salesman Sale
- COLUMN,59,Model Text
- COLUMN,60,Colour Cf
- COLUMN,61,Model Line
- COLUMN,62,Model Line_vpp5q
- COLUMN,63,Mod Lin Specify_vpp5q
- COLUMN,64,Workshop Model
- COLUMN,65,Mileage
- COLUMN,66,Motor Code
- COLUMN,67,Drive Code
- COLUMN,68,Colour Code
- COLUMN,69,Make
- COLUMN,70,Make Cd
- COLUMN,71,Global Make Cd
- COLUMN,72,Description_Global_Make
- COLUMN,73,Orig Inv Date
- COLUMN,74,Latest Inv Date
- COLUMN,75,Invoice Date
- COLUMN,76,Hauptbetrieb
- COLUMN,77,Standort_Verkaufskostenstelle
- COLUMN,78,Verkäufer
- COLUMN,79,Fabrikat_ori
- COLUMN,80,Model
- COLUMN,81,Modellbez
- COLUMN,82,Fahrgestellnr
- COLUMN,83,Fahrzeugart
- COLUMN,84,Fahrzeugtyp
- COLUMN,85,Kunde
- COLUMN,86,Kundenart
- COLUMN,87,Geschäftsart
- COLUMN,88,Farbe
- COLUMN,89,ECC_Status_Text
- COLUMN,90,FZG
- COLUMN,91,FZG_1
- COLUMN,92,FZG_Liste_1
- COLUMN,93,Sel Name_EK_vpp43
- COLUMN,94,Einkäufer
- COLUMN,95,Vorbesitzer
- COLUMN,96,FZG_Liste_2
- COLUMN,97,FZG_Liste_3
- COLUMN,98,FZG_Liste_4
- COLUMN,99,Menge
- COLUMN,100,Standtage
- COLUMN,101,Fabrikat
- COLUMN,102,Mandant
- COLUMN,103,Department_unit_change_hist
- COLUMN,104,Unique Ident_unit_change_hist
- COLUMN,105,Maximun_Unique_Ident
- COLUMN,106,Standort
- COLUMN,107,Mandant
|