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.

SQL Abfrage mit Intersect

Empfohlene Antworten

Veröffentlicht

Ich habe folgendes Problem.

Starte ich in Oracle 8i folgende Abfrage im SQL Worksheet, sagt mir das Programm, dass es den Befehl intersect nicht gibt. Ich habe diesen Befehel aber schon öfters benutzt, nur plötzlich sagt mir das Programm, dass es diesen Befehl nicht kenne.

Hier ist mal der SQL Code


(select distinct c.cname,sum(dollars) as Umsatz, o.month

from  customers c, orders o

where o.cid=c.cid

group by c.cname, o.month

having o.month<>'mar')


intersect


(select distinct c.cname,sum(dollars) as Umsatz, o.month

from  customers c, orders o

where o.cid=c.cid

group by c.cname, o.month

having o.month<>'jan');

Oder ist da syntaktisch was falsch. Ich weiß wirklich nicht weiter.

SP2-0042: Unbekannter Befehl "intersect" - restliche Zeile wurde ignoriert.

Obwohl der Januar wurde "weggeschnitten". Aber irgendwie finde ich das komisch.

Habe jetzt das richtige Ergebnis. Besser ist es nämlich den Exists Operator zu verwenden und in dieser Subquery den Verbund herzustellen.

Also habe ich es jetzt so und Oracle meckert nicht:



select distinct c.cname,sum(dollars)

from  customers c, orders o

where not exists(select *

                  from orders o

                  where o.month = 'mar' and

                        o.cid = c.cid)

                        group by c.cname

                                                 intersect


select distinct c.cname,sum(dollars)

from  customers c, orders o

where not exists(select *

                  from orders o

                  where o.month = 'jan'

                  and   c.cid = o.cid)

                  group by c.cname;

Trotzdem verstehe ich die blöde Fehlermeldung von Oracle nicht. ;) Na ja...

Wieso funktionierte das ganze denn nicht mit dem Ungleich-Operator? Dort hatte ich doch auch einen Verbund hergestellt.

Weiß niemand eine Antwort?

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.