title: Postgres column must appear in the GROUP BY clause or be used in an aggregate function error.
body: <p>I have the following table: </p>
  
  <pre><code>portal=# \d+ accounts_version
                                        Table "public.accounts_version"
            Column          |            Type             | Modifiers | Storage  | Stats target | Description 
  --------------------------+-----------------------------+-----------+----------+--------------+-------------
   id                       | integer                     | not null  | plain    |              | 
   status                   | account_status              |           | plain    |              | 
   adwords_id               | character varying(20)       |           | extended |              | 
   nickname                 | character varying(48)       |           | extended |              | 
   account_budget           | double precision            |           | plain    |              | 
   remaining_account_budget | double precision            |           | plain    |              | 
   daily_budget             | double precision            |           | plain    |              | 
   currency                 | character varying(12)       |           | extended |              | 
   exchange_rate            | double precision            |           | plain    |              | 
   login                    | character varying(48)       |           | extended |              | 
   password                 | character varying(48)       |           | extended |              | 
   billing                  | character varying(48)       |           | extended |              | 
   auto_tag_on              | boolean                     |           | plain    |              | 
   mcc_id                   | integer                     |           | plain    |              | 
   vps_id                   | integer                     |           | plain    |              | 
   client_id                | integer                     |           | plain    |              | 
   transaction_id           | bigint                      | not null  | plain    |              | 
   end_transaction_id       | bigint                      |           | plain    |              | 
   operation_type           | smallint                    | not null  | plain    |              | 
   country                  | character varying(24)       |           | extended |              | 
   external_comment         | text                        |           | extended |              | 
   internal_comment         | text                        |           | extended |              | 
   batch                    | character varying(48)       |           | extended |              | 
   updated_at               | timestamp without time zone |           | plain    |              | 
  Indexes:
      "accounts_version_pkey" PRIMARY KEY, btree (id, transaction_id)
      "ix_accounts_version_end_transaction_id" btree (end_transaction_id)
      "ix_accounts_version_operation_type" btree (operation_type)
      "ix_accounts_version_transaction_id" btree (transaction_id)
  </code></pre>
  
  <p>I am trying to query for the latest entry into this table for each adwords_id. </p>
  
  <p>So I am started writing my sql query like this: </p>
  
  <pre><code>SELECT * FROM accounts_version GROUP BY adwords_id; 
  </code></pre>
  
  <p>And I am getting the following error: </p>
  
  <pre><code>ERROR:  column "accounts_version.id" must appear in the GROUP BY clause or be used in an aggregate function
  LINE 1: SELECT * FROM accounts_version
  
             ^
  </code></pre>
  
  <p>I am running postgres 9.5. Any idea what is causing this? </p>