123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402 |
- COGNOS QUERY
- STRUCTURE,1,1
- DATABASE,GC_LOCOSOFT
- DATASOURCENAME,C:\GlobalCube\System\LOCOSOFT\IQD\serv_teile\Aftersales_Rechnungen_neu.imr
- TITLE,Aftersales_Rechnungen_neu.imr
- BEGIN SQL
- select c254 as c1,
- c253 as c2,
- c252 as c3,
- c251 as c4,
- c250 as c5,
- c249 as c6,
- c248 as c7,
- c247 as c8,
- c246 as c9,
- c245 as c10,
- c244 as c11,
- c243 as c12,
- c242 as c13,
- c241 as c14,
- c240 as c15,
- c239 as c16,
- c238 as c17,
- c237 as c18,
- c236 as c19,
- c235 as c20,
- c234 as c21,
- c233 as c22,
- c232 as c23,
- c231 as c24,
- c230 as c25,
- c229 as c26,
- c228 as c27,
- c227 as c28,
- c226 as c29,
- c225 as c30,
- c224 as c31,
- c223 as c32,
- c222 as c33,
- c221 as c34,
- c220 as c35,
- c219 as c36,
- c218 as c37,
- c217 as c38,
- c172 as c39,
- c216 as c40,
- c215 as c41,
- c214 as c42,
- c213 as c43,
- c212 as c44,
- c211 as c45,
- c210 as c46,
- c209 as c47,
- c208 as c48,
- c207 as c49,
- c206 as c50,
- c205 as c51,
- c204 as c52,
- c203 as c53,
- c202 as c54,
- c201 as c55,
- c200 as c56,
- c199 as c57,
- c198 as c58,
- c197 as c59,
- c196 as c60,
- c195 as c61,
- c194 as c62,
- c193 as c63,
- c192 as c64,
- c191 as c65,
- c190 as c66,
- c189 as c67,
- c188 as c68,
- c187 as c69,
- c186 as c70,
- c185 as c71,
- c184 as c72,
- c183 as c73,
- c182 as c74,
- c181 as c75,
- c158 as c76,
- c180 as c77,
- c179 as c78,
- c178 as c79,
- c177 as c80,
- c176 as c81,
- c175 as c82,
- c174 as c83,
- c173 as c84,
- c172 as c85,
- c171 as c86,
- c170 as c87,
- c169 as c88,
- c168 as c89,
- c167 as c90,
- c166 as c91,
- c165 as c92,
- c164 as c93,
- c163 as c94,
- c162 as c95,
- c161 as c96,
- c160 as c97,
- c159 as c98,
- c158 as c99,
- c157 as c100,
- c156 as c101,
- c155 as c102,
- c154 as c103,
- '' as c104,
- c153 as c105,
- c152 as c106,
- c151 as c107,
- c150 as c108,
- c149 as c109,
- c148 as c110,
- c149 as c111,
- c148 as c112,
- c147 as c113,
- (0) as c114,
- (0) as c115,
- (0) as c116,
- (0) as c117,
- (0) as c118,
- (0) as c119,
- (0) as c120,
- (0) as c121,
- (0) as c122,
- 1 as c123,
- XCOUNT(c254 for c141) as c124,
- 1 / (XCOUNT(c254 for c141)) as c125,
- c146 as c126,
- c141 as c127,
- c145 as c128,
- c144 as c129,
- '' as c130,
- '' as c131,
- '' as c132,
- '' as c133,
- '' as c134,
- '' as c135,
- c143 as c136,
- c142 as c137
- from
- (select (CASE WHEN ((CASE WHEN (T1."invoice_type" = 5) THEN (((od_left((cast_numberToString(cast_integer(T5."employee_number"))),4)) || ' - ' || T5."name")) ELSE (T10."Serviceberater") END) IS NOT NULL) THEN (((od_left((cast_numberToString(cast_integer(T1."invoice_type"))),1)) || (od_left((cast_numberToString(cast_integer(T1."invoice_number"))),9))) || ' - ' || (CASE WHEN (T1."invoice_type" = 5) THEN (((od_left((cast_numberToString(cast_integer(T5."employee_number"))),4)) || ' - ' || T5."name")) ELSE (T10."Serviceberater") END) || ' - ' || (CASE WHEN (T4."first_name" IS NULL) THEN ((od_left((cast_numberToString(cast_integer(T4."customer_number"))),7)) || ' - ' || T4."family_name") ELSE ((od_left((cast_numberToString(cast_integer(T4."customer_number"))),7)) || ' - ' || T4."first_name" || ' ' || T4."family_name") END)) ELSE (((od_left((cast_numberToString(cast_integer(T1."invoice_type"))),1)) || (od_left((cast_numberToString(cast_integer(T1."invoice_number"))),9))) || ' - ' || (CASE WHEN (T4."first_name" IS NULL) THEN ((od_left((cast_numberToString(cast_integer(T4."customer_number"))),7)) || ' - ' || T4."family_name") ELSE ((od_left((cast_numberToString(cast_integer(T4."customer_number"))),7)) || ' - ' || T4."first_name" || ' ' || T4."family_name") END)) END) as c141,
- CASE WHEN (T1."invoice_type" = 5) THEN (((od_left((cast_numberToString(cast_integer(T5."employee_number"))),4)) || ' - ' || T5."name")) ELSE (T10."Serviceberater") END as c142,
- T10."Serviceberater" as c143,
- CASE WHEN ((extract(DAY FROM (now()) - ((cdatetime(T1."invoice_date"))))) <= 4) THEN ((CASE WHEN ((CASE WHEN (T1."invoice_type" = 5) THEN (((od_left((cast_numberToString(cast_integer(T5."employee_number"))),4)) || ' - ' || T5."name")) ELSE (T10."Serviceberater") END) IS NOT NULL) THEN (((od_left((cast_numberToString(cast_integer(T1."invoice_type"))),1)) || (od_left((cast_numberToString(cast_integer(T1."invoice_number"))),9))) || ' - ' || (CASE WHEN (T1."invoice_type" = 5) THEN (((od_left((cast_numberToString(cast_integer(T5."employee_number"))),4)) || ' - ' || T5."name")) ELSE (T10."Serviceberater") END) || ' - ' || (CASE WHEN (T4."first_name" IS NULL) THEN ((od_left((cast_numberToString(cast_integer(T4."customer_number"))),7)) || ' - ' || T4."family_name") ELSE ((od_left((cast_numberToString(cast_integer(T4."customer_number"))),7)) || ' - ' || T4."first_name" || ' ' || T4."family_name") END)) ELSE (((od_left((cast_numberToString(cast_integer(T1."invoice_type"))),1)) || (od_left((cast_numberToString(cast_integer(T1."invoice_number"))),9))) || ' - ' || (CASE WHEN (T4."first_name" IS NULL) THEN ((od_left((cast_numberToString(cast_integer(T4."customer_number"))),7)) || ' - ' || T4."family_name") ELSE ((od_left((cast_numberToString(cast_integer(T4."customer_number"))),7)) || ' - ' || T4."first_name" || ' ' || T4."family_name") END)) END)) ELSE null END as c144,
- (cdatetime(T1."invoice_date")) as c145,
- (od_left((od_left((cast_numberToString(cast_integer(T1."vehicle_number"))),5)) || ' - ' || T9."description",100)) as c146,
- (od_left((ucase(T9."description")),3)) as c147,
- T9."description" as c148,
- T8."description" as c149,
- T7."free_form_model_text" as c150,
- T7."model_code" as c151,
- T7."free_form_make_text" as c152,
- T7."make_number" as c153,
- CASE WHEN (T1."invoice_type" = 5) THEN ('Teile') ELSE ('Service') END as c154,
- CASE WHEN (T1."invoice_type" = 6) THEN ('GWL') WHEN ((T1."invoice_type" = 4) or (T4."customer_number" IN (1000000,1000001,1000002,1000003,1000010))) THEN ('intern') ELSE ('extern') END as c155,
- (od_left(((rtrim((cast_numberToString(cast_integer(T3."skr51_cost_center"))))) || ' - ' || T6."skr51_cost_center_name"),1)) as c156,
- (rtrim((cast_numberToString(cast_integer(T3."skr51_sales_channel"))))) || ' - ' || T6."skr51_sales_channel_name" as c157,
- T3."skr51_make" as c158,
- (rtrim((cast_numberToString(cast_integer(T3."skr51_cost_center"))))) || ' - ' || T6."skr51_cost_center_name" as c159,
- CASE WHEN (T3."debit_or_credit" = 'H') THEN (((cast_float(T3."posted_value"))) / 100 * -1) ELSE (((cast_float(T3."posted_value"))) / 100) END as c160,
- CASE WHEN (T4."first_name" IS NULL) THEN ((od_left((cast_numberToString(cast_integer(T4."customer_number"))),7)) || ' - ' || T4."family_name") ELSE ((od_left((cast_numberToString(cast_integer(T4."customer_number"))),7)) || ' - ' || T4."first_name" || ' ' || T4."family_name") END as c161,
- T4."family_name" as c162,
- T4."first_name" as c163,
- T4."customer_number" as c164,
- (od_left((cast_numberToString(cast_integer(T5."employee_number"))),4)) || ' - ' || T5."name" as c165,
- T5."is_master_craftsman" as c166,
- T5."is_business_executive" as c167,
- T5."salesman_number" as c168,
- T5."mechanic_number" as c169,
- T5."name" as c170,
- T5."employee_number" as c171,
- T3."accounting_date" as c172,
- (cast_numberToString(cast_integer(T3."branch_number"))) as c173,
- T3."subsidiary_to_company_ref" as c174,
- CASE WHEN (T3."skr51_cost_unit" BETWEEN 1 AND 49) THEN ('Neuwagen') WHEN (T3."skr51_cost_unit" BETWEEN 50 AND 59) THEN ('Gebrauchtwagen') WHEN (T3."skr51_cost_unit" BETWEEN 60 AND 69) THEN ('Teile & Zubehör') WHEN (T3."skr51_cost_unit" BETWEEN 70 AND 79) THEN ('Service') WHEN (T3."skr51_cost_unit" = 0) THEN ('Ohne Kostenträger') ELSE null END as c175,
- T4."zip_code" as c176,
- T3."previously_used_account_no" as c177,
- T3."skr51_cost_unit" as c178,
- T3."skr51_sales_channel" as c179,
- T3."skr51_cost_center" as c180,
- T3."skr51_branch" as c181,
- T3."day_of_actual_accounting" as c182,
- T3."days_for_cash_discount" as c183,
- T3."vat_key" as c184,
- T3."account_statement_page" as c185,
- T3."account_statement_number" as c186,
- T3."vat_id_number" as c187,
- T3."vehicle_reference" as c188,
- T3."posting_text" as c189,
- T3."term_of_payment" as c190,
- T3."cash_discount" as c191,
- T3."journal_line" as c192,
- T3."journal_page" as c193,
- T3."last_dunning_date" as c194,
- T3."dunning_level" as c195,
- T3."invoice_number" as c196,
- T3."invoice_date" as c197,
- T3."employee_number" as c198,
- T3."serial_number_each_month" as c199,
- T3."account_form_page_line" as c200,
- T3."account_form_page_number" as c201,
- CASE WHEN (T3."nominal_account_number" = 5701) THEN ((rtrim((cast_numberToString(cast_integer(T3."nominal_account_number"))))) || '_' || (rtrim((cast_numberToString(cast_integer(T3."skr51_cost_center")))))) ELSE ((rtrim((cast_numberToString(cast_integer(T3."nominal_account_number")))))) END as c202,
- T3."nominal_contra_account" as c203,
- T3."customer_contra_account" as c204,
- T3."branch_number" as c205,
- T3."posted_count" as c206,
- T3."debit_or_credit" as c207,
- (cast_float(T3."posted_value")) as c208,
- T3."document_date" as c209,
- T3."clearing_number" as c210,
- T3."is_balanced" as c211,
- T3."nominal_account_number" as c212,
- T3."customer_number" as c213,
- T3."position_in_document" as c214,
- T3."document_number" as c215,
- T3."document_type" as c216,
- (od_left((cast_numberToString(cast_integer(T1."invoice_type"))),1)) || (od_left((cast_numberToString(cast_integer(T1."invoice_number"))),9)) as c217,
- T1."total_net" as c218,
- T1."total_gross" as c219,
- T1."part_disposal" as c220,
- T1."part_rebate" as c221,
- T1."part_amount_gross" as c222,
- T1."part_amount_net" as c223,
- T1."job_rebate" as c224,
- T1."job_amount_gross" as c225,
- T1."job_amount_net" as c226,
- T1."used_part_vat_value" as c227,
- T1."reduced_vat_value" as c228,
- T1."reduced_vat_percentage" as c229,
- T1."reduced_vat_basevalue" as c230,
- T1."full_vat_value" as c231,
- T1."full_vat_percentage" as c232,
- T1."full_vat_basevalue" as c233,
- T1."vehicle_number" as c234,
- T1."internal_cost_account" as c235,
- T1."creating_employee" as c236,
- T1."odometer_reading" as c237,
- T1."credit_invoice_number" as c238,
- T1."credit_invoice_type" as c239,
- T1."is_credit" as c240,
- T1."is_own_vehicle" as c241,
- T1."cancelation_employee" as c242,
- T1."cancelation_date" as c243,
- T1."cancelation_number" as c244,
- T1."is_canceled" as c245,
- T1."service_date" as c246,
- T1."invoice_date" as c247,
- T1."order_customer" as c248,
- T1."paying_customer" as c249,
- T1."subsidiary" as c250,
- T1."invoice_number" as c251,
- T2."description" as c252,
- T2."type" as c253,
- T1."invoice_type" as c254
- from ((((((((("dbo"."invoices" T1 left outer join "dbo"."invoice_types" T2 on T2."type" = T1."invoice_type") left outer join "dbo"."journal_accountings" T3 on T3."invoice_number" = T1."invtype_invnr") left outer join "dbo"."customers_suppliers" T4 on T4."customer_number" = T1."paying_customer") left outer join "dbo"."employees" T5 on T1."creating_employee" = T5."employee_number") left outer join "dbo"."accounts_characteristics" T6 on (((((T6."skr51_branch" = T3."skr51_branch") and (T6."skr51_make" = T3."skr51_make")) and (T6."skr51_cost_center" = T3."skr51_cost_center")) and (T6."skr51_sales_channel" = T3."skr51_sales_channel")) and (T6."skr51_cost_unit" = T3."skr51_cost_unit")) and (T6."subsidiary_to_company_ref" = T3."subsidiary_to_company_ref")) left outer join "dbo"."vehicles" T7 on T1."vehicle_number" = T7."internal_number") left outer join "dbo"."makes" T8 on T7."make_number" = T8."make_number") left outer join "dbo"."models" T9 on (T7."make_number" = T9."make_number") and (T7."model_code" = T9."model_code")) left outer join QSS."C:\GlobalCube\System\LOCOSOFT\Catalogs\..\IQD\Serv_Teile\Serviceberater_Rechnung.ims" T10 on T1."invtype_invnr" = T10."invtype_invnr")
- where (((((T1."invoice_type" BETWEEN 2 AND 6) and ((od_left((cast_numberToString(cast_integer(T3."nominal_account_number"))),1)) IN ('4','5','7','8'))) and (T1."invoice_date" >= DATE '2019-01-01')) and (T1."is_canceled" <> 1)) and (((length((rtrim((cast_numberToString(cast_integer(T3."nominal_account_number"))))) || 'Z') - 1)) = 4))
- order by c141 asc,c215 asc,c214 asc,c217 asc
- ) D1
- END SQL
- COLUMN,0,Invoice Type
- COLUMN,1,Type_Invoice_Types
- COLUMN,2,Description_Invoice_Types
- COLUMN,3,Invoice Number
- COLUMN,4,Subsidiary
- COLUMN,5,Paying Customer
- COLUMN,6,Order Customer
- COLUMN,7,Invoice Date
- COLUMN,8,Service Date
- COLUMN,9,Is Canceled
- COLUMN,10,Cancelation Number
- COLUMN,11,Cancelation Date
- COLUMN,12,Cancelation Employee
- COLUMN,13,Is Own Vehicle
- COLUMN,14,Is Credit
- COLUMN,15,Credit Invoice Type
- COLUMN,16,Credit Invoice Number
- COLUMN,17,Odometer Reading
- COLUMN,18,Creating Employee
- COLUMN,19,Internal Cost Account
- COLUMN,20,Vehicle Number
- COLUMN,21,Full Vat Basevalue
- COLUMN,22,Full Vat Percentage
- COLUMN,23,Full Vat Value
- COLUMN,24,Reduced Vat Basevalue
- COLUMN,25,Reduced Vat Percentage
- COLUMN,26,Reduced Vat Value
- COLUMN,27,Used Part Vat Value
- COLUMN,28,Job Amount Net
- COLUMN,29,Job Amount Gross
- COLUMN,30,Job Rebate
- COLUMN,31,Part Amount Net
- COLUMN,32,Part Amount Gross
- COLUMN,33,Part Rebate
- COLUMN,34,Part Disposal
- COLUMN,35,Total Gross
- COLUMN,36,Total Net
- COLUMN,37,Inv_Type_Invoice_Number
- COLUMN,38,Accounting Date
- COLUMN,39,Document Type
- COLUMN,40,Document Number
- COLUMN,41,Position In Document
- COLUMN,42,Customer Number
- COLUMN,43,Nominal Account Number
- COLUMN,44,Is Balanced
- COLUMN,45,Clearing Number
- COLUMN,46,Document Date
- COLUMN,47,Posted Value
- COLUMN,48,Debit Or Credit
- COLUMN,49,Posted Count
- COLUMN,50,Branch Number
- COLUMN,51,Customer Contra Account
- COLUMN,52,Nominal Contra Account
- COLUMN,53,Contra Account Text
- COLUMN,54,Account Form Page Number
- COLUMN,55,Account Form Page Line
- COLUMN,56,Serial Number Each Month
- COLUMN,57,Employee Number
- COLUMN,58,Invoice Date_falsch
- COLUMN,59,Invoice Number
- COLUMN,60,Dunning Level
- COLUMN,61,Last Dunning Date
- COLUMN,62,Journal Page
- COLUMN,63,Journal Line
- COLUMN,64,Cash Discount
- COLUMN,65,Term Of Payment
- COLUMN,66,Posting Text
- COLUMN,67,Vehicle Reference
- COLUMN,68,Vat Id Number
- COLUMN,69,Account Statement Number
- COLUMN,70,Account Statement Page
- COLUMN,71,Vat Key
- COLUMN,72,Days For Cash Discount
- COLUMN,73,Day Of Actual Accounting
- COLUMN,74,Skr51 Branch
- COLUMN,75,Skr51 Make
- COLUMN,76,Skr51 Cost Center
- COLUMN,77,Skr51 Sales Channel
- COLUMN,78,Skr51 Cost Unit
- COLUMN,79,Previously Used Account No
- COLUMN,80,Free Form Accounting Text
- COLUMN,81,Free Form Document Text
- COLUMN,82,Hauptbetrieb
- COLUMN,83,Standort
- COLUMN,84,Invoice Date_accounting
- COLUMN,85,Employee Number_Employees
- COLUMN,86,Name_Employees
- COLUMN,87,Mechanic Number_Employees
- COLUMN,88,Salesman Number_Employees
- COLUMN,89,Is Business Executive_Employees
- COLUMN,90,Is Master Craftsman_Employees
- COLUMN,91,Serviceberater_Rg_Steller
- COLUMN,92,Customer Number_Customers_Suppliers
- COLUMN,93,First Name_Customers_Suppliers
- COLUMN,94,Family Name_Customers_Suppliers
- COLUMN,95,Kunde
- COLUMN,96,Betrag
- COLUMN,97,Kostenstelle
- COLUMN,98,Marke
- COLUMN,99,Kundenart
- COLUMN,100,KST_1_Stelle
- COLUMN,101,Umsatzart
- COLUMN,102,Auftragsart
- COLUMN,103,Geschäftsart
- COLUMN,104,Make Number
- COLUMN,105,Free Form Make Text
- COLUMN,106,Model Code
- COLUMN,107,Free Form Model Text
- COLUMN,108,Description_Makes
- COLUMN,109,Description_Models
- COLUMN,110,Fabrikat
- COLUMN,111,Model_Detail
- COLUMN,112,Model
- COLUMN,113,Umsatz Lohn
- COLUMN,114,Umsatz FL
- COLUMN,115,Einsatz FL
- COLUMN,116,Umsatz Teile
- COLUMN,117,Einsatz Teile
- COLUMN,118,Umsatz MW
- COLUMN,119,Einsatz MW
- COLUMN,120,Umsatz Sonst.
- COLUMN,121,Einsatz Sonst.
- COLUMN,122,DG_1
- COLUMN,123,DG_2
- COLUMN,124,DG
- COLUMN,125,Fahrzeug
- COLUMN,126,Order Number
- COLUMN,127,Invoice_Date_Uhrzeit
- COLUMN,128,Order Number_Rg_Ausg
- COLUMN,129,Konto Nr
- COLUMN,130,Konto Bezeichnung
- COLUMN,131,Ebene1
- COLUMN,132,Ebene2
- COLUMN,133,Ebene3
- COLUMN,134,Ebene4
- COLUMN,135,Serviceberater_order_pos
- COLUMN,136,Serviceberater
|