SELECT
tableA.col1,
tableA.col2,
LEFT(tableB.col3, 4) as person
FROM tableA
LEFT JOIN tableB ON
tableB.col1 = tableA.col1 AND
tableB.col2 = tableA.col2
WHERE tableA.col3 = '000000'
AND tableA.col4 <> ''
AND person = 'Zeus'
ORDER BY tableA.col1, tableA.col4 ASC;
---
col1 col4 person
001 abc Zeus
002 abc Zeus
003 xyz Zeus
004 xyz Zeus
+Benötigen Sie Hilfe bei Kombination SQL-Abfragen
SELECT
tableC.col1,
SUM(tableC.col2) as cost
FROM tableC
WHERE tableC.col3 = 'L'
GROUP BY tableC.col1, tableC.col3;
---
col1 cost
001 23462
002 25215
003 92381
004 29171
=
col1 col4 person cost
001 abc Zeus 23462
002 abc Zeus 25215
003 xyz Zeus 92381
004 xyz Zeus 29171
Wie mache ich das? Ich habe versucht, die zweite Abfrage als eine geschachtelte Auswahl in der obersten, aber ich konnte es nicht zum Laufen bringen. Beide Ergebnissätze haben die gleichen col1
Werte, die eindeutig sind, also denke ich, dass sie dazu gehören müssen? Und schließlich ist die person
wo die Abfrage jedes Mal anders, wenn ich es ausführen werde.
Danke, funktioniert perfekt. – Slime