>Do you mean
>
>select Temp.NoThread, count(*) over (partition by Temp.NoThread) as CountThreads
> from (SELECT Top 10 NoThread FROM Thread ORDER BY Numero DESC) Temp
This returns 1 for all records.
If you look at the main page, there is a top 10 for the most recent threads. Until tonight, I was doing a main SQL to collect the most recent 10 threads. Then, in the loop, for the HTML table generation, which is a For/Next 10 times, I was doing another SQL to collect the amount of messages in each thread. Tonight, I tried to simplify that by doing it all in the main SQL and avoid doing another SQL for each of those 10 records that I process in the loop. However, I cannot put the COUNT(*) in the inner SQL as this count would only apply on the WHERE clause of that inner SQL and this wouldn't be good as it wouldn't cover the entire table. So, I have to find a way to get the count once I have found the 10 records I need to deal with. And, this can only be done at the external level such as you mentioned in your message. We just need to find the right syntax.