R
Robert
I need help with the SQL syntax of a query. All I want to do is retrieve
the corresponding value of Val for the Last DateAndTime grouped by TabIndex.
Of course, you cannot do this in a simple aggregate query because it wont
let me have Val unless I group on it, but I cannot group on Val. So I have
to join the table to itself but I cannot get it to work.
FloatTable
Floatid
TabIndex
DateAndTime
Val
Can anyone provide the correct syntax to join FloatTable to itself and
retrieve Val for the last (most recent) DateAndTime grouped by TabIndex?
This does not work:
SELECT Val
FROM FloatTable AS A1 INNER JOIN [SELECT max(DateAndTime) AS
MaxOfDateAndTime, TagIndex FROM FloatTable WHERE (DateAndTime Like "*" &
"12/24/2008" & "*" AND Status<>"U") GROUP BY TagIndex ] AS B1 ON
a1.dateandtime=b1.MaxOfDateAndTime AND a1.tagindex=b1.tagindex;
Not sure if my constants have anything to do with the problem.
Rob
the corresponding value of Val for the Last DateAndTime grouped by TabIndex.
Of course, you cannot do this in a simple aggregate query because it wont
let me have Val unless I group on it, but I cannot group on Val. So I have
to join the table to itself but I cannot get it to work.
FloatTable
Floatid
TabIndex
DateAndTime
Val
Can anyone provide the correct syntax to join FloatTable to itself and
retrieve Val for the last (most recent) DateAndTime grouped by TabIndex?
This does not work:
SELECT Val
FROM FloatTable AS A1 INNER JOIN [SELECT max(DateAndTime) AS
MaxOfDateAndTime, TagIndex FROM FloatTable WHERE (DateAndTime Like "*" &
"12/24/2008" & "*" AND Status<>"U") GROUP BY TagIndex ] AS B1 ON
a1.dateandtime=b1.MaxOfDateAndTime AND a1.tagindex=b1.tagindex;
Not sure if my constants have anything to do with the problem.
Rob