Registriert seit: 26. Aug 2004
Ort: Nebel auf Amrum
3.154 Beiträge
Delphi 7 Enterprise
|
Re: SQL: Tabellenausgabe, User mit gleichen Einträgen
23. Sep 2008, 01:26
SQL-Code:
SELECT *
FROM multitabelle a
INNER JOIN multitabelle b
ON a.user < b.user
WHERE CASE
WHEN a.ip1 = b.ip1
AND a.ip2 = b.ip2
AND a.ip3 = b.ip3
AND a.ip4 = b.ip4 THEN 100
WHEN a.ip1 = b.ip1
AND a.ip2 = b.ip2
AND a.ip3 = b.ip3 THEN 75
WHEN a.ip1 = b.ip1
AND a.ip2 = b.ip2 THEN 50
WHEN a.ip1 = b.ip1 THEN 25
ELSE 0
END >= 50
Und mit Ausgabe...
SQL-Code:
SELECT *
FROM (SELECT CASE
WHEN a.ip1 = b.ip1
AND a.ip2 = b.ip2
AND a.ip3 = b.ip3
AND a.ip4 = b.ip4 THEN 100
WHEN a.ip1 = b.ip1
AND a.ip2 = b.ip2
AND a.ip3 = b.ip3 THEN 75
WHEN a.ip1 = b.ip1
AND a.ip2 = b.ip2 THEN 50
WHEN a.ip1 = b.ip1 THEN 25
ELSE 0
END mw,
a.user userA, a.ip1 a_ip1, a.ip2 a_ip2, a.ip3 a_ip3, a.ip4 a_ip4,
b.user userB, b.ip1 b_ip1, b.ip2 b_ip2, b.ip3 b_ip3, b.ip4 b_ip4
FROM multitabelle a
INNER JOIN multitabelle b
ON a.user < b.user) x
WHERE mw >= 50
|
|
Zitat
|