Beim Verknüpfen von zwei Tabellen mit einer Eins-zu-Viele-Beziehung möchte ich ein Ergebnis anzeigen, das alle Werte in der Tabelle mit null
Werten in der einen Tabelle anzeigt.SQL Implizierte Nullwerte in verknüpfter Tabelle
Hier ist ein Beispiel:
tbl_Platform: priKey = PlatformID
PlatformID PlatformDesc
1 Application
2 Cloud
3 Storage
4 Backup
tbl_Missed: priKey = CustomerID + Woche + PlatformID
CustomerID Week Missed Platform ID
49 1 2017-05-19 1
Ausgang gewünscht:
CustomerID Week Missed PlatformDesc
49 1 2017-05-19 Application
49 1 null Cloud
49 1 null Storage
49 1 null Backup
Die nächstgelegene ich habe in der Lage zu kommen, wird mit einem Cross-Join wie folgt:
SELECT
dbo.tbl_Missed.CustomerID,
dbo.tbl_Missed.Week,
dbo.tbl_Missed.Missed,
dbo.tbl_Platform.PlatformDesc
FROM
dbo.tbl_Platform
CROSS JOIN dbo.tbl_MissedSPT
Was mir gibt:
49 1 2017-05-19 Application
49 1 2017-05-19 Cloud
49 1 2017-05-19 Storage
49 1 2017-05-19 Backup