no, it shouldn't've
the subquery produces an intermediate table result which is used as the data source for the outer query's FROM clause, yes?
well, that intermediate table result has a single column, called "table"
thus, the outer table cannot count the distinct values of a column called "timestamp" because that column doesn't exist