DB2 - Problembeschreibung
| Problem IC76993 | Status: Geschlossen |
DB2 MAY PRODUCE INCORRECT RESULTS EXECUTING A QUERY CONTAINING A PREDICATE ON MAX/MIN APPLIED ON A CASE EXPRESSION | |
| Produkt: | |
DB2 FOR LUW / DB2FORLUW / 970 - DB2 | |
| Problembeschreibung: | |
A query may produce incorrect results if the following
conditions are satisfied:
1. The query containing a predicate on the output of a MAX or
MIN function
2. The subselect containing the MAX or MIN function has more 1
or more GROUP BY and output columns
3. The input to the MAX or MIN function is a CASE expression
4. The else clause of the CASE Expression is NULL.
Sample query:
SELECT
T1.c1 ,T2.c2
FROM
T1, T2
LEFT OUTER JOIN (
select
a.c1, a.c2,
max(case when b.c1 = 1 then b.c2 else
null end) AS col1, <---------- input to MAX is a CASE
expression
max(case when b.c1 = 2 then b.c2 else
null end) AS col2
from
t1 a, t3 b
where
a.c1 = b.c1
and a.c2 = b.c2
group
by a.c1, a.c2 <------------
Group by and output columns
) tmp
ON
t1.c1 = tmp.c1
and t2.c2 = tmp.c2
WHERE
( t1.c1 = t2.c2 )
AND tmp.col1 = 'Y' <---------- predicate on
MAX/MIN
Workaround:
Rewrite the query to include other MAX columns in the output
list.
eg.
SELECT
T1.c1 ,T2.c2,
TMP.COL2 <---------------- added column to
output list
FROM
T1, T2
LEFT OUTER JOIN (
select
a.c1, a.c2,
max(case when b.c1 = 1 then b.c2 else
null end) AS col1,
max(case when b.c1 = 2 then b.c2 else
null end) AS col2
from
t1 a, t3 b
where
a.c1 = b.c1
and a.c2 = b.c2
group
by a.c1, a.c2
) tmp
ON
t1.c1 = tmp.c1
and t2.c2 = tmp.c2
WHERE
( t1.c1 = t2.c2 )
AND tmp.col1 = 'Y' | |
| Problem-Zusammenfassung: | |
**************************************************************** * USERS AFFECTED: * * All * **************************************************************** * PROBLEM DESCRIPTION: * * See APAR description * **************************************************************** * RECOMMENDATION: * * Please upgrade to DB2 970 fixpack 5 * **************************************************************** | |
| Local-Fix: | |
| verfügbare FixPacks: | |
DB2 Version 9.7 Fix Pack 5 for Linux, UNIX, and Windows | |
| Lösung | |
Problem is first fixed in DB2 970 fixpack 5 | |
| Workaround | |
keiner bekannt / siehe Local-Fix | |
| Weitere Daten | |
Datum - Problem gemeldet : Datum - Problem geschlossen : Datum - der letzten Änderung: | 15.06.2011 12.12.2011 12.12.2011 |
| Problem behoben ab folgender Versionen (IBM BugInfos) | |
9.7.0 | |
| Problem behoben lt. FixList in der Version | |
| 9.7.0.5 |
|