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.

Datumsbereich in einzelne Zellen (SQL)

Empfohlene Antworten

Veröffentlicht

Hallo,

ich habe eine table die neben einer Artikelnummer auch einen Preis mit einem Start und Enddatum enthält. Sieht also in etwa so aus:

Artikelnummer Preis Startdatum Enddatum

1234 12,50 01.01.2011 10.02.2011

1234 11,90 11.02.2011

2345 23,09 30.11.2010

Wenn unter Enddatum nichts steht ist der Preis heute noch gültig.

Ich benötige nun eine Abfrage, die mir für einen Zeitraum der letzten zum Beispiel 30 Tage folgendes liefert:

Artikelnummer Preis Datum

1234 12,50 25.01.2011

1234 12,50 26.01.2011

1234 12,50 27.01.2011

....

1234 11,90 11.02.2011

2345 ......

Also für jeden Tag eine Zeile mit entsprechendem Preis.

Ich verwende Oracle SQL und werde diese Abfrage mehrmals im Monat laufen lassen und verschiedene Zeiträume wählen müssen, mal die letzten 30 Tage, mal 20 Tage etc.

Leider habe ich noch nicht einmal ansatzweise eine Idee wie ich das ohne komplizierte Pivotisierung erreichen kann.

Danke,

Nico

Hey,

also ich glaube so müsste es ca. gehen, zumindest vom Ansatz her

ADATE und EDATE sind der Anfang und ende von deinen 30 Tagen

SELECT * FROM TABLE WHERE STARTDATAUM > ADATE AND STARTDATUM < EDATE

AND ENDDATUM IS NULL

UNION

SELECT * FROM TABLE WHERE STARTDATUM > ADATE AND ENDDATUM < EDATE

AND ENDDATUM IS NOT NULL

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.