title: Count distinct values with OVER(PARTITION BY id)
body: <p>Is it possible to count distinct values in conjunction with window functions like <code>OVER(PARTITION BY id)</code>? Currently my query is as follows:</p>
  
  <pre><code>SELECT congestion.date, congestion.week_nb, congestion.id_congestion,
     congestion.id_element,
  ROW_NUMBER() OVER(
      PARTITION BY congestion.id_element
      ORDER BY congestion.date),
  COUNT(DISTINCT congestion.week_nb) OVER(
      PARTITION BY congestion.id_element
  ) AS week_count
  FROM congestion
  WHERE congestion.date &gt;= '2014.01.01'
  AND congestion.date &lt;= '2014.12.31'
  ORDER BY id_element, date
  </code></pre>
  
  <p>However, when I try to execute the query I get the following error:</p>
  
  <pre><code>"COUNT(DISTINCT": "DISTINCT is not implemented for window functions"
  </code></pre>