I am trying to find and compare max (datetime) value for one row in the table using a self join. e.g cte_q stores: ID =1 time='2010-11-8 00:00' Query is: Select ID from cte_q a where a.time=(select max(b.time) from cte_q b where
b.ID) but this is a never ending query in SQL
2005.It keeps on running though there is only 1 record in cte_q. I don't really know why.any sort of help is appreciated.