title: Join two tables and remove duplicates
body: <p>I'm trying to join two tables. Where table2 has duplates.</p>
  
  <p>The tables look something like </p>
  
  <pre><code>CREATE TABLE ta 
      (
       id int, 
       cno varchar(30),
       d1 varchar(30),
       d2 int
      );
  CREATE TABLE tb 
      (
       id int, 
       cno varchar(30),
       cn1 varchar(30),
       cn2 int
      );
  
  INSERT INTO ta
  (id, cno, d1, d2)
  VALUES
  (1, '1234','a',2),
  (2, '6456','j',3),
  (3, '5456','h',4),
  (4, '4454','g',5);
  
  INSERT INTO tb
  (id, cno, cn1, cn2)
  VALUES
  (1, '1234', 'a', 21),
  (1, '1234', 'a', 22),
  (2, '6456', 'b', 33),
  (2, '6456', 'c', 34),
  (2, '6456', 'c', 35),
  (3, '5456', 'c', 36),
  (4, '4454', 'c', 37);
  </code></pre>
  
  <p>I was able to get the result <a href="http://sqlfiddle.com/#!2/b282e3/1" rel="nofollow">http://sqlfiddle.com/#!2/b282e3/1</a> in MySQL. However when I run it in Postgresql I get an error <a href="http://sqlfiddle.com/#!15/b282e/4" rel="nofollow">http://sqlfiddle.com/#!15/b282e/4</a></p>
  
  <p>Output should be like <a href="http://sqlfiddle.com/#!2/b282e3/1" rel="nofollow">http://sqlfiddle.com/#!2/b282e3/1</a></p>
  
  <pre class="lang-none prettyprint-override"><code>CNO     CN1 CN2 D1  D2
  1234    a   21  a   2
  4454    c   37  g   5
  5456    c   36  h   4
  6456    b   33  j   3
  </code></pre>
  
  <p>Any alternatives for this in Psql?</p>