Hallo Leute!
Ich muss aus einer Tabelle mittels Pl/SQL-Statements einen Wert zu einem Attribut auslesen.
Das Attribut hat ab gewissen Stichtagen unterschiedliche Werte, das ist die Tabelle:
Code:
[Spalte attr] [Spalte dateofvalue] [spalte price]
homeAddress 01.07.14 5
homeAddress 01.01.15 7
mobilePhone 01.01.14 5
mobilePhone 01.11.14 2
maritalStatus 01.11.13 1
age 01.01.14 2
age 01.06.14 1
hobbies 01.01.14 0,5
musicTaste 01.07.14 0,1
electronics 01.01.14 0,5
electronics 01.07.14 0,25
socialContacts 01.01.14 1
socialContacts 01.01.15 1,75
Aber so weit bin ich nicht, dass ich den Wert im bezug auf das aktuelle Datum auslese.
Ich habe nur mal testweise probiert, den spätesten Zeitpunkt auszulesen:
Code:
SELECT DISTINCT attr, dateofvalue, price FROM Informationvalues
WHERE attr IN (SELECT attr, MAX(DATEOFVALUE) FROM Informationvalues GROUP BY attr)
GROUP BY attr, dateofvalue, price;
Dazu schreibt Oracle SQL Developer:
ORA-00913: Zu viele Werte
00913. 00000 - "too many values"
*Cause:
*Action:
Fehler in Zeile: 2 Spalte: 16
Wenn ich das hingegen ausführe
Code:
SELECT DISTINCT attr, dateofvalue, price FROM Informationvalues
WHERE dateofvalue IN (SELECT MAX(DATEOFVALUE) FROM Informationvalues GROUP BY attr)
GROUP BY attr, dateofvalue, price;
kommen wieder alle Attribute zu jedem Zeitpunkt.
Was mache ich falsch?