Merge Multiple records into a single record
<p>I have the following query that produces multiple records for a single id. I'm trying to figure out how to merge these multiple records into one record:</p>

<pre><code>SELECT DISTINCT id, gender, dateofbirth, city, state, zip
FROM t
</code></pre>

<p>This may give me the following resultset:</p>

<pre><code>1, M, 2000-01-01, dallas, tx, 12345
1, M, 2000-01-01, NULL, NULL, NULL
</code></pre>

<p>What I want is a single record:</p>

<pre><code>1, M, 2000-01-01, dallas, tx, 12345
</code></pre>

<p>A similar scenario occurs when the second row has different data:</p>

<pre><code>1, M, 2000-01-01, dallas, tx, 12345
1, M, 2000-01-01, houston, tx, 67890
</code></pre>

<p>In this case I would just want to pick one of the records and ignore the other in order to only have a single record per id.</p>

<p>Is there a way to do this in PostgreSQL? I've tried coalesce to no avail and is wondering if there is some way to handle this.</p>