COGNOS QUERY STRUCTURE,1,1 DATABASE,ARIntelligence DATASOURCENAME,C:\GlobalCube\System\ARI\IQD\OP\OP_ARI.imr TITLE,OP_ARI.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, XSUM(c63 for c2) 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 from (select c104 as c1, c192 as c2, c191 as c3, c190 as c4, c189 as c5, c188 as c6, c108 as c7, c187 as c8, c186 as c9, c185 as c10, c184 as c11, c183 as c12, c182 as c13, c135 as c14, c181 as c15, c180 as c16, c179 as c17, c178 as c18, c177 as c19, c137 as c20, c176 as c21, c175 as c22, c174 as c23, c173 as c24, c172 as c25, c171 as c26, c170 as c27, c169 as c28, c168 as c29, c125 as c30, c167 as c31, c166 as c32, c165 as c33, c164 as c34, c163 as c35, c162 as c36, c161 as c37, c160 as c38, c159 as c39, c158 as c40, c157 as c41, c156 as c42, c155 as c43, c154 as c44, c153 as c45, c152 as c46, c151 as c47, c150 as c48, c149 as c49, c148 as c50, c147 as c51, c146 as c52, c145 as c53, c144 as c54, c143 as c55, c142 as c56, c141 as c57, c140 as c58, c139 as c59, c138 as c60, XSUM(c149 for c104) as c61, XCOUNT(c192 for c104) as c62, (XSUM(c149 for c104)) / (XCOUNT(c192 for c104)) as c63, c137 as c65, '1' as c66, c136 as c67, c135 as c68, c134 as c69, c133 as c70, c132 as c71, c131 as c72, c130 as c73, c129 as c74, c128 as c75, c127 as c76, c126 as c77, c125 as c78, c124 as c79, c123 as c80, '' as c81, c122 as c82, c121 as c83, c120 as c84, c119 as c85, c118 as c86, c117 as c87, c116 as c88, c115 as c89, c114 as c90, c113 as c91, c112 as c92, c111 as c93, c110 as c94, c109 as c95, (c108) / (XCOUNT(c192 for c104)) as c96, c107 as c97, c106 as c98, c105 as c99 from (select T1."Entry No_" as c104, CASE WHEN (T1."On Hold" IN ('HAF','KAS','UNF')) THEN ('UNF') ELSE (T1."On Hold") END as c105, CASE WHEN (T1."On Hold" = 'HAF') THEN ('HAFT') WHEN (T1."On Hold" = 'KAS') THEN ('KASKO') WHEN (T1."On Hold" = 'WSS') THEN ('WSS') ELSE null END as c106, T1."Message to Recipient" as c107, (cast_float(T1."Sales (LCY)")) as c108, CASE WHEN ((CASE WHEN ((CASE WHEN (T1."Main Area" = 0) THEN ('Sonstige') WHEN (T1."Main Area" = 1) THEN ('TZ') WHEN (T1."Main Area" = 2) THEN ('Verkauf') WHEN (T1."Main Area" = 3) THEN ('Service') WHEN (T1."Main Area" = 5) THEN ('Kassenbuchung') ELSE ('nicht zuzuordnen') END) IN ('Service')) THEN (T7."No_" || ' - ' || T7."First Name" || ' ' || T7."Last Name") WHEN ((CASE WHEN (T1."Main Area" = 0) THEN ('Sonstige') WHEN (T1."Main Area" = 1) THEN ('TZ') WHEN (T1."Main Area" = 2) THEN ('Verkauf') WHEN (T1."Main Area" = 3) THEN ('Service') WHEN (T1."Main Area" = 5) THEN ('Kassenbuchung') ELSE ('nicht zuzuordnen') END) IN ('Verkauf','Kassenbuchung','Sonstige','TZ')) THEN (T5."Code" || ' - ' || T5."Name") ELSE ('N.N.') END) IS NULL) THEN ('N.N.') ELSE ((CASE WHEN ((CASE WHEN (T1."Main Area" = 0) THEN ('Sonstige') WHEN (T1."Main Area" = 1) THEN ('TZ') WHEN (T1."Main Area" = 2) THEN ('Verkauf') WHEN (T1."Main Area" = 3) THEN ('Service') WHEN (T1."Main Area" = 5) THEN ('Kassenbuchung') ELSE ('nicht zuzuordnen') END) IN ('Service')) THEN (T7."No_" || ' - ' || T7."First Name" || ' ' || T7."Last Name") WHEN ((CASE WHEN (T1."Main Area" = 0) THEN ('Sonstige') WHEN (T1."Main Area" = 1) THEN ('TZ') WHEN (T1."Main Area" = 2) THEN ('Verkauf') WHEN (T1."Main Area" = 3) THEN ('Service') WHEN (T1."Main Area" = 5) THEN ('Kassenbuchung') ELSE ('nicht zuzuordnen') END) IN ('Verkauf','Kassenbuchung','Sonstige','TZ')) THEN (T5."Code" || ' - ' || T5."Name") ELSE ('N.N.') END)) END as c109, CASE WHEN ((CASE WHEN (T1."Main Area" = 0) THEN ('Sonstige') WHEN (T1."Main Area" = 1) THEN ('TZ') WHEN (T1."Main Area" = 2) THEN ('Verkauf') WHEN (T1."Main Area" = 3) THEN ('Service') WHEN (T1."Main Area" = 5) THEN ('Kassenbuchung') ELSE ('nicht zuzuordnen') END) IN ('Service')) THEN (T7."No_" || ' - ' || T7."First Name" || ' ' || T7."Last Name") WHEN ((CASE WHEN (T1."Main Area" = 0) THEN ('Sonstige') WHEN (T1."Main Area" = 1) THEN ('TZ') WHEN (T1."Main Area" = 2) THEN ('Verkauf') WHEN (T1."Main Area" = 3) THEN ('Service') WHEN (T1."Main Area" = 5) THEN ('Kassenbuchung') ELSE ('nicht zuzuordnen') END) IN ('Verkauf','Kassenbuchung','Sonstige','TZ')) THEN (T5."Code" || ' - ' || T5."Name") ELSE ('N.N.') END as c110, T8."Last Name" as c111, T8."First Name" as c112, T8."No_" as c113, T7."Last Name" as c114, T7."First Name" as c115, T7."No_" as c116, T6."Name" as c117, T6."Code" as c118, T5."Name" as c119, T5."Code" as c120, T4."Service Advisor No_" as c121, T4."Salesperson Code" as c122, CASE WHEN (T1."Customer No_" LIKE '%Garan%') THEN ('Garantie') WHEN ((CASE WHEN (T3."First Name" <> '') THEN (T3."Last Name" || ', ' || T3."First Name" || ' - ' || T3."No_") ELSE (T3."Name" || ' - ' || T3."No_") END) LIKE '%BMW%') THEN ((CASE WHEN (T3."First Name" <> '') THEN (T3."Last Name" || ', ' || T3."First Name" || ' - ' || T3."No_") ELSE (T3."Name" || ' - ' || T3."No_") END)) WHEN (T1."Customer No_" LIKE '%ASI%') THEN ((CASE WHEN (T3."First Name" <> '') THEN (T3."Last Name" || ', ' || T3."First Name" || ' - ' || T3."No_") ELSE (T3."Name" || ' - ' || T3."No_") END)) WHEN ((CASE WHEN (T3."First Name" <> '') THEN (T3."Last Name" || ', ' || T3."First Name" || ' - ' || T3."No_") ELSE (T3."Name" || ' - ' || T3."No_") END) LIKE '%Automag%') THEN ('Intern') ELSE ('Kundenforderungen') END as c123, CASE WHEN (T1."Customer No_" LIKE '%Garan%') THEN ('Garantie') ELSE ('Kundenforderungen') END as c124, T1."Last Issued Reminder Level" as c125, CASE WHEN (((extract(DAY FROM (now()) - T1."Due Date"))) BETWEEN 0 AND 14) THEN ('< 2 Wochen') WHEN (((extract(DAY FROM (now()) - T1."Due Date"))) BETWEEN 15 AND 28) THEN ('2 - 4 Wochen') WHEN (((extract(DAY FROM (now()) - T1."Due Date"))) BETWEEN 29 AND 42) THEN ('4 - 6 Wochen') WHEN (((extract(DAY FROM (now()) - T1."Due Date"))) BETWEEN 43 AND 84) THEN ('6 - 12 Wochen') WHEN (((extract(DAY FROM (now()) - T1."Due Date"))) > 84) THEN ('> 12 Wochen') WHEN (((extract(DAY FROM (now()) - T1."Due Date"))) < 0) THEN ('noch nicht fällig') ELSE null END as c126, (extract(DAY FROM (now()) - T1."Due Date")) as c127, CASE WHEN (T1."Main Area" = 0) THEN ('Sonstige') WHEN (T1."Main Area" = 1) THEN ('TZ') WHEN (T1."Main Area" = 2) THEN ('Verkauf') WHEN (T1."Main Area" = 3) THEN ('Service') WHEN (T1."Main Area" = 5) THEN ('Kassenbuchung') ELSE ('nicht zuzuordnen') END as c128, CASE WHEN (T1."Comment" <> '') THEN (T1."Document No_" || ' - ' || T1."Description" || ' - ' || T1."Comment" || ' - ' || T1."User ID" || ' - MS:' || (cast_numberToString(cast_integer(T1."Last Issued Reminder Level")))) ELSE (T1."Document No_" || ' - ' || T1."Description" || ' - ' || T1."User ID" || ' - MS:' || (cast_numberToString(cast_integer(T1."Last Issued Reminder Level")))) END as c129, CASE WHEN (T3."First Name" <> '') THEN (T3."Last Name" || ', ' || T3."First Name" || ' - ' || T3."No_") ELSE (T3."Name" || ' - ' || T3."No_") END as c130, T3."First Name" as c131, T3."Last Name" as c132, T3."Name" as c133, T3."No_" as c134, T1."User ID" as c135, CASE WHEN (T1."Branch Code" IN ('01BSPKW')) THEN ('10') WHEN (T1."Branch Code" IN ('02BSMOT')) THEN ('20') WHEN (T1."Branch Code" IN ('04SFH')) THEN ('40') WHEN (T1."Branch Code" IN ('05WT')) THEN ('50') WHEN (T1."Branch Code" IN ('06BI')) THEN ('60') WHEN (T1."Branch Code" IN ('07TR')) THEN ('70') ELSE (T1."Branch Code") END as c136, T1."Due Date" as c137, T2."Initial Document Type" as c138, T2."Gen_ Prod_ Posting Group" as c139, T2."Gen_ Bus_ Posting Group" as c140, T2."Initial Entry Global Dim_ 2" as c141, T2."Initial Entry Global Dim_ 1" as c142, T2."Initial Entry Due Date" as c143, (cast_float(T2."Credit Amount")) as c144, (cast_float(T2."Debit Amount")) as c145, T2."Source Code" as c146, T2."User ID" as c147, T2."Customer No_" as c148, (cast_float(T2."Amount")) as c149, T2."Document No_" as c150, T2."Document Type" as c151, T2."Posting Date" as c152, T2."Entry Type" as c153, T2."Cust_ Ledger Entry No_" as c154, T2."Entry No_" as c155, T1."Salesperson Code 2" as c156, T1."Service Advisor No_" as c157, T1."Comment" as c158, T1."Cash Reg_ Receipt No_" as c159, T1."Factory No_" as c160, T1."VIN" as c161, T1."Pmt_ Disc_ Base" as c162, T1."Main Area" as c163, T1."Branch Code" as c164, T1."Customer Group Code" as c165, T1."Direct Debit Mandate ID" as c166, T1."Dimension Set ID" as c167, T1."No_ Series" as c168, T1."Document Date" as c169, T1."Closed by Amount (LCY)" as c170, T1."Journal Batch Name" as c171, T1."Closed by Amount" as c172, T1."Closed at Date" as c173, T1."Closed by Entry No_" as c174, T1."Positive" as c175, T1."Pmt_ Discount Date" as c176, T1."Open" as c177, T1."Applies-to Doc_ No_" as c178, T1."Applies-to Doc_ Type" as c179, T1."On Hold" as c180, T1."Source Code" as c181, T1."Salesperson Code" as c182, T1."Global Dimension 2 Code" as c183, T1."Global Dimension 1 Code" as c184, T1."Customer Posting Group" as c185, T1."Sell-to Customer No_" as c186, (cast_float(T1."Profit (LCY)")) as c187, T1."Description" as c188, T1."Document No_" as c189, T1."Document Type" as c190, T1."Posting Date" as c191, T1."Customer No_" as c192 from "Gottstein7x"."dbo"."AH Gottstein$Detailed Cust_ Ledg_ Entry" T2, (((((("Gottstein7x"."dbo"."AH Gottstein$Cust_ Ledger Entry" T1 left outer join "Gottstein7x"."dbo"."AH Gottstein$Customer" T3 on T1."Customer No_" = T3."No_") left outer join "Gottstein7x"."dbo"."AH Gottstein$Sales Invoice Header" T4 on T1."Document No_" = T4."No_") left outer join "Gottstein7x"."dbo"."AH Gottstein$Salesperson_Purchaser" T5 on T1."Salesperson Code" = T5."Code") left outer join "Gottstein7x"."dbo"."AH Gottstein$Salesperson_Purchaser" T6 on T1."Service Advisor No_" = T6."Code") left outer join "Gottstein7x"."dbo"."AH Gottstein$Employee" T7 on T4."Service Advisor No_" = T7."No_") left outer join "Gottstein7x"."dbo"."AH Gottstein$Employee" T8 on T4."Salesperson Code" = T8."No_") where (T1."Entry No_" = T2."Cust_ Ledger Entry No_") and (T1."Open" = 1) ) D2 ) D1 order by c2 asc,c1 asc END SQL COLUMN,0,Entry No COLUMN,1,Customer No COLUMN,2,Posting Date COLUMN,3,Document Type COLUMN,4,Document No COLUMN,5,Description COLUMN,6,Sales (lcy) COLUMN,7,Profit (lcy) COLUMN,8,Sell-to Customer No COLUMN,9,Customer Posting Group COLUMN,10,Global Dimension 1 Code COLUMN,11,Global Dimension 2 Code COLUMN,12,Salesperson Code COLUMN,13,User Id COLUMN,14,Source Code COLUMN,15,On Hold_ori COLUMN,16,Applies-to Doc Type COLUMN,17,Applies-to Doc No COLUMN,18,Open COLUMN,19,Due Date COLUMN,20,Pmt Discount Date COLUMN,21,Positive COLUMN,22,Closed By Entry No COLUMN,23,Closed At Date COLUMN,24,Closed By Amount COLUMN,25,Journal Batch Name COLUMN,26,Closed By Amount (lcy) COLUMN,27,Document Date COLUMN,28,No Series COLUMN,29,Last Issued Reminder Level COLUMN,30,Dimension Set Id COLUMN,31,Direct Debit Mandate Id COLUMN,32,Customer Group Code COLUMN,33,Branch Code COLUMN,34,Main Area COLUMN,35,Pmt Disc Base COLUMN,36,Vin COLUMN,37,Factory No COLUMN,38,Cash Reg Receipt No COLUMN,39,Comment COLUMN,40,Service Advisor No COLUMN,41,Salesperson Code 2 COLUMN,42,Entry No COLUMN,43,Cust Ledger Entry No COLUMN,44,Entry Type COLUMN,45,Posting Date COLUMN,46,Document Type_detail_cust COLUMN,47,Document No_detail COLUMN,48,Amount COLUMN,49,Customer No COLUMN,50,User Id_detail_cust COLUMN,51,Source Code COLUMN,52,Debit Amount COLUMN,53,Credit Amount COLUMN,54,Initial Entry Due Date COLUMN,55,Initial Entry Global Dim 1 COLUMN,56,Initial Entry Global Dim 2 COLUMN,57,Gen Bus Posting Group COLUMN,58,Gen Prod Posting Group COLUMN,59,Initial Document Type COLUMN,60,Saldo_Beleg_1 COLUMN,61,Anzahl_Sätze_Entry_No COLUMN,62,offen COLUMN,63,Gesamt offen KD (Info) COLUMN,64,Invoice Date COLUMN,65,Hauptbetrieb COLUMN,66,Standort COLUMN,67,Sel Name_alt COLUMN,68,No_Customer COLUMN,69,Name_Customer COLUMN,70,Last Name_Customer COLUMN,71,First Name_Customer COLUMN,72,Kunde COLUMN,73,Beleg COLUMN,74,Bereich COLUMN,75,Tage COLUMN,76,Staffel COLUMN,77,Mahnstufe COLUMN,78,Forderungsart COLUMN,79,Abwarten COLUMN,80,Leasing COLUMN,81,Salesperson Code_Sales_Inv_Header COLUMN,82,Service Advisor No_Sales_Inv_Header COLUMN,83,Code_Salesperson_Purchaser_Verkauf COLUMN,84,Name_Salesperson_Purchaser_Verkauf COLUMN,85,Code_Salesperson_Purchaser_Service COLUMN,86,Name_Salesperson_Purchaser_Service COLUMN,87,No_Employee_Service_Advisor COLUMN,88,First Name_Employee_Service_Advisor COLUMN,89,Last Name_Employee_Service_Advisor COLUMN,90,No_Employee_Salesperson_Code COLUMN,91,First Name_Employee_Salesperson_Code COLUMN,92,Last Name_Employee_Salesperson_Code COLUMN,93,Sel Name_ori COLUMN,94,Sel Name COLUMN,95,Betrag Rg. COLUMN,96,Message To Recipient COLUMN,97,Haft_Kasko COLUMN,98,On Hold