I have an SQL Server table Cascading with following structure:
+----+--------+----------------+ +----------------+-----------+
| ID | NodeID | ActivationTime | | ActivationTime | NodeCount |
+----+--------+----------------+ +----------------+-----------+
| 1 | 448 | 1 | | 1 | 1 |
| 2 | 195 | 2 | | 2 | 3 |
| 3 | 504 | 2 | | 3 | 6 |
| 4 | 609 | 2 | | ... | ... |
| 5 | 15 | 3 | | ... | ... |
| 6 | 31 | 3 | => | ... | ... |
| 7 | 56 | 3 | | ... | ... |
| 8 | 461 | 3 | | ... | ... |
| 9 | 585 | 3 | | ... | ... |
| 10 | 345 | 3 | | ... | ... |
| .. | ... | ... | | ... | ... |
+----+--------+----------------+ +----------------+-----------+
I need to calculate the number of times NodeID is appearing in the table with DISTINCT ActivationTime. For instance, 1 node at ActivationTime 1, 3 nodes at ActivationTime 2, 6 nodes at ActivationTime 3 and so on. The desired result is shown at the right side.
I tried the following unsuccessful query:
SELECT DISTINCT(ActivationTime) FROM CASCADING WHERE ActivationTIme IN
(SELECT DISTINCT(COUNT(ActivationTime)) AS NodeCount FROM CASCADING
GROUP BY ActivationTime)