Registriert seit: 26. Aug 2004
Ort: Nebel auf Amrum
3.154 Beiträge
Delphi 7 Enterprise
|
Re: Sum()-Daten aus 2 Tabellen in einer Query
21. Feb 2008, 02:04
Vielleicht so...
SQL-Code:
SELECT id, number, SUM(value) value
FROM (SELECT SUM(billvalue) AS value, 1 AS flag, p.id, p.number
FROM bill x
INNER JOIN project p
ON p.id = x.projectid
GROUP BY p.id, p.number
UNION ALL
SELECT SUM(projecttime) AS value, 2 AS flag, p.id, p.number
FROM projecttime x
INNER JOIN project p
ON p.id = x.projectid
GROUP BY p.id, p.number) x
GROUP BY id, number
Gruss
Thorsten
|
|
Zitat
|