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.

Permutation in SQL (Alle Kombinationsmöglichkeiten)

Empfohlene Antworten

Hallo! :)

Ich habe folgendes Problem zu lösen und komme auf keinen grünen Zweig:

Ich habe n Datensätze aus einer Tabelle.

Meinetwegen: A, B, C und D

Und ich versuche einen Algorithmus zu entwickeln der mir alle (4! =) 24 Kombinationsmöglichkeiten berechnet, also:

ABCD

BADC

CDAB

usw.

Leider fehlt mir der Ansatz. Hat einer von euch so etwas schonmal gemacht?

Bitte um Hilfe.

nachdem das nicht im forum "algorithmik" gepostet wurde: welche DB bzw. welcher SQL-dialekt?

s'Amstel

Also MS SQL Server 2005, T-SQL.

Kartesisches Produkt hab ich auch schon probiert, aber ich krieg's so auch net hin. Das Ergebnis soll folgendermaßen aussehen:

Jedes Element aus ABCD wird in die neue Tabele geschrieben, somit haben wir nach der Prozedur (4 *24 =) 96 Datensätze in der Tabelle stehen.

Jeder Datensatz eines "Kombinationsblocks" bekommt ne nicht indizierte ID um Kombiblöcke wieder eindeutig identifizieren zu können.

Bsp:

NEUE TABELLE

ID ELEMENT

1 A

1 B

1 C

1 D

2 B

2 A

2 D

2 C

3 C

3 B

3 A

3 D

usw.

Ist das verständlich? :confused:

Für eine Datenbank macht es keinen Unterschied in welcher Reihenfolge du die Werte speicherst.

1 A

1 B

1 C

1 D

2 B

2 A

2 D

2 C

ist praktisch das gleiche

du müsstest die Position im Block abspeichern

1 1 A

1 2 B

1 3 C

1 4 D

2 1 B

2 2 A

2 3 D

2 4 C

Alle Permutationen dürftest du mit einem Cross? Join erhalten (keine Ahnung wie man das in JOIN-Schreibweise schreibt)

SELECT a1.wert, a2.wert, a3.wert, a4.wert FROM a a1, a a2, a a3, a a4

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.