Count distinct values with OVER(PARTITION BY id)

No, as the error message states, DISTINCT is not implemented with windows functions. Aplying info from this link into your case you could use something like: WITH uniques AS ( SELECT congestion.id_element, COUNT(DISTINCT congestion.week_nb) AS unique_references FROM congestion WHERE congestion.date >= ‘2014.01.01’ AND congestion.date <= ‘2014.12.31’ GROUP BY congestion.id_element ) SELECT congestion.date, congestion.week_nb, congestion.id_congestion, congestion.id_element, … Read more

Removing a set of letters from a string

translate() replaces a set of single characters (passed as a string) with another set of characters (also passed as a string), for example: translate(‘abcdef’, ‘ace’, ‘XYZ’) –> ‘XbYdZf’ replace() replaces occurrences of a string of arbitrary length with another string: replace(‘abcdef’, ‘bc’, ‘FOO’) –> ‘aFOOdef’

PostgreSQL: create database with UTF8 encoding same as in MySQL (including character set, encoding, and lc_type)

Yes, you can be more specific. For example: CREATE DATABASE “scratch” WITH OWNER “postgres” ENCODING ‘UTF8’ LC_COLLATE = ‘en_US.UTF-8’ LC_CTYPE = ‘en_US.UTF-8’; Also I recommend to read the following pages about locales and collations in PostgreSQL: http://www.postgresql.org/docs/current/interactive/locale.html http://www.postgresql.org/docs/current/interactive/collation.html

tech