Zum Inhalt springen
View in the app

A better way to browse. Learn more.

Fachinformatiker.de

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Aus Zwei mach Eins! Datenbankabfrage

Empfohlene Antworten

Veröffentlicht

Hi,

ich habe folgenden Skript:

SELECT NVL(a.code_b, 'Total') "Cost Center", TO_CHAR(ROUND(SUM(a.net_curr_amount/a.rate), 2), '9,999,999,990.99') "Sales"   

FROM IFSAPP.instant_invoice_item a

WHERE a.code_b IS NOT NULL

GROUP BY ROLLUP (a.code_[/code]




Dadurch erhalte ich folgendes Ergebnis:



[code]Cost Center Revenue 01 48,503.25 10 13,514.90 20 24,824.98 30 71,766,745.19 40 314,491.74 45 136,726.73 70 56,000.00 901 -1,376.63 902 20,221.00 906 3,805.67 993 659.41 999 16,545.69 Total 72,400,661.92
Das passt soweit alles, die Zahlen sind korrekt. Dazu habe ich einen zweiten Skript, welche sich nur durch die WHERE-Bedingung unterscheiden:
SELECT NVL(a.code_b, 'Total') "Cost Center", TO_CHAR(ROUND(SUM(a.net_curr_amount/a.rate), 2), '9,999,999,990.99') "Sales"   

FROM IFSAPP.instant_invoice_item a

WHERE a.code_h IN ('410102', '410202', '410302', '410402', '410502')

AND a.code_b IS NOT NULL

GROUP BY ROLLUP (a.code_[/code]




Dadurch erhalte ich folgendes Ergebnis:



[code]Cost Center Sales 01 14,736.50 10 40,395.27 20 16,463.83 30 71,783,812.85 40 433,786.38 45 136,476.73 70 56,000.00 901 -1,376.63 902 20,221.00 906 3,805.67 999 10.00 Total 72,504,331.60
Die Zahlen stimmen ebenfalls, jedoch möchte ich diese beiden Skripte vereinen, dass das Ganze dann so aussieht:
Cost Center	Revenue			Sales

01		48,503.25		14,736.50

10		13,514.90		40,395.27

20		24,824.98		16,463.83

30		71,766,745.19		71,783,812.85

40		314,491.74		433,786.38

45		136,726.73		136,476.73

70		56,000.00		56,000.00

901		-1,376.63		-1,376.63

902		20,221.00		20,221.00

906		3,805.67		3,805.67

993		659.41			

999		16,545.69		10.00

Total		72,400,661.92		72,504,331.60

Ich habe mich jetzt damit schon Stunden beschäftigt, leider kam dabei aber nichts brauchbares raus...

Welche Möglichkeit habe ich, um einen Bericht anzufertigen, der "Revenue" und "Sales" vereint?

Vielen Dank für eure Hilfe!

Freundliche Grüße

iceQ7

Hi,

versuch mal folgendes:

SELECT t1.CC as "Cost Center",

t1.Sales as revenue,

t2.sales

from (

( SELECT NVL( a.code_b, 'Total' ) as CC,

TO_CHAR( ROUND( SUM( net_curr_amount / rate ), 2 ), '9,999,999,990.99' ) as sales

FROM IFSAPP.instant_invoice_item

WHERE code_b IS NOT NULL

GROUP BY ROLLUP ( code_b ) ) t1,

( SELECT NVL( a.code_b, 'Total' ) as CC,

TO_CHAR( ROUND( SUM( net_curr_amount / rate ), 2 ), '9,999,999,990.99' ) as Sales

FROM IFSAPP.instant_invoice_item

WHERE code_h IN ( '410102', '410202', '410302', '410402', '410502' )

AND code_b IS NOT NULL

GROUP BY ROLLUP ( code_b ) ) t1

)

where t1.CC = t1.CC (+)

gruß

emetiel

Hi,

Danke schon einmal für deine Hilfe! Leider erhielt ich eine Fehlermeldung, sobald ich das Statement ausführe: ORA-00907: missing right parenthesis.

Mir stellt sich nur die Frage, wo genau?

Hi,

sorry, versuch mal t1 hier und da durch t2 zu ersetzen :)

Habs im Skript markiert

SELECT t1.CC as "Cost Center",

t1.Sales as revenue,

t2.sales

from (

( SELECT NVL( a.code_b, 'Total' ) as CC,

TO_CHAR( ROUND( SUM( net_curr_amount / rate ), 2 ), '9,999,999,990.99' ) as sales

FROM IFSAPP.instant_invoice_item

WHERE code_b IS NOT NULL

GROUP BY ROLLUP ( code_b ) ) t1,

( SELECT NVL( a.code_b, 'Total' ) as CC,

TO_CHAR( ROUND( SUM( net_curr_amount / rate ), 2 ), '9,999,999,990.99' ) as Sales

FROM IFSAPP.instant_invoice_item

WHERE code_h IN ( '410102', '410202', '410302', '410402', '410502' )

AND code_b IS NOT NULL

GROUP BY ROLLUP ( code_b ) ) t2

)

where t1.CC = t2.CC (+)

Archiv

Dieses Thema wurde archiviert und kann nicht mehr beantwortet werden.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.