Registriert seit: 26. Aug 2004
Ort: Nebel auf Amrum
3.154 Beiträge
Delphi 7 Enterprise
|
Re: je ein Eintrag mit dem höchsten Datum (Group By ?)
29. Feb 2008, 21:44
Ok, hier ein neuer Versuch...
SQL-Code:
SELECT 'a' AS typ, wp.wsid, wp.thedate, wp.thevalue,
s.wsid AS ws_id, p.projectid AS project_id
FROM wsprogress wp
INNER JOIN workstep s
ON wp.wsid = s.wsid
INNER JOIN project p
ON s.projectid = p.projectid
WHERE p.id = 110
AND wp.thedate <= :bis_datum
AND CAST(wp.thedate + wp.thetime AS TIMESTAMP)
= (SELECT MAX(CAST( thedate + thetime AS TIMESTAMP))
FROM wsprogress
WHERE wsid = wp.wsid
AND thedate <= :bis_datum)
UNION
SELECT 'b' AS typ, wp.wsid, wp.thedate, wp.thevalue,
s.wsid AS ws_id, p.projectid AS project_id
FROM wsprogress wp
INNER JOIN workstep s
ON wp.wsid = s.wsid
INNER JOIN project p
ON s.projectid = p.projectid
WHERE p.id = 110
AND CAST(wp.thedate + wp.thetime AS TIMESTAMP)
= (SELECT MAX(CAST( thedate + thetime AS TIMESTAMP))
FROM wsprogress
WHERE wsid = wp.wsid)
Gruss
Thorsten
|
|
Zitat
|