Hi,
I fail to reduce the values from table A. Why does it return 3(all) records instead of only 2? I though the exists check every row for true or false?!
query statement
--------------------------------------------------
select WBT_ID, fk_user_id, Score, Lesson_Time, Modified_Time
from TestResults A
where exists
(
select max(modified_time) as Modified_Time, WBT_ID
from TestResults B
where FK_User_ID = 'michael' and B.Modified_Time = A.Modified_Time
group by wbt_id
)
query results
--------------------------------------------------------
5 michael incomplete NULL 0000:03:40.00 2005-06-06 13:01:42.107
5 michael incomplete NULL 0000:04:00.00 2005-06-06 13:02:03.467
1 michael incomplete NULL 0000:01:00.00 2005-06-06 13:02:59.000
I fail to reduce the values from table A. Why does it return 3(all) records instead of only 2? I though the exists check every row for true or false?!
query statement
--------------------------------------------------
select WBT_ID, fk_user_id, Score, Lesson_Time, Modified_Time
from TestResults A
where exists
(
select max(modified_time) as Modified_Time, WBT_ID
from TestResults B
where FK_User_ID = 'michael' and B.Modified_Time = A.Modified_Time
group by wbt_id
)
query results
--------------------------------------------------------
5 michael incomplete NULL 0000:03:40.00 2005-06-06 13:01:42.107
5 michael incomplete NULL 0000:04:00.00 2005-06-06 13:02:03.467
1 michael incomplete NULL 0000:01:00.00 2005-06-06 13:02:59.000