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.

Empfohlene Antworten

Veröffentlicht

Hallo Forum,

ich habe folgendes Problem: Ich habe Kundendaten in denen steht in einem Feld eine Anzahl wie oft etwas verschickt werden soll. Solange die Zahl 1 da steht soll die Adresse nur einmal angezeigt werden. Wenn aber die Zahl 2 da steht soll die Adresse zweimal untereinander angezeigt werden. Ich habe keine Idee, wie ich das mit einem SELECT-Statement hinbekommen könnte, hat jemand von euch eine Idee?

Beste Grüße aus Gießen

Patrick

2 Vorschläge:

1. Benutz ein rekursives SQL

2. Wenn du den Wertebereich von Anzahl sehr sicher einschränken kannst:

SELECT * FROM a WHERE anzahl>0

UNION

SELECT * FROM a WHERE anzahl>1

UNION

SELECT * FROM a WHERE anzahl>2

usw.

wobei die 1. Lösung solider ist, auch wenn es etwas Einarbeitung kostet

Google mal nach "rekursion sql vater kind", der 2. Link

Hier ist ein SQL das ungefähr das macht was du suchst. Ersetze Stufe durch Anzahl und bau deine benötigten Felder ein. In Daten werden einfach nur 3 Testsätze erzeugt (gibt es in db2 eine spezielle Tabelle für so was?)


WITH 

  daten(id, werte, stufe) AS (SELECT DISTINCT 1, 111, 4 FROM sysibm.views UNION SELECT DISTINCT 2, 222, 1 FROM sysibm.views UNION SELECT DISTINCT 3, 333, 2 FROM sysibm.views)

  , rek (id, werte, stufe) AS 

    (

      SELECT 

        daten.id

        , daten.werte

        , daten.stufe 

      FROM 

        daten 


      UNION ALL 


      SELECT 

        kind.id

        , kind.werte

        , vater.stufe-1 

      FROM 

        rek vater

        , daten kind 

      WHERE 

        vater.id=kind.id 

        AND

        vater.stufe>1

    ) 

  SELECT id, werte FROM rek

Erstelle ein Konto oder melde dich an, um einen Kommentar zu schreiben.

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.