title: PostgreSQL - Assign value to each row based on criteria
body: <p>I have the below table.</p>
  
  <pre>
  date    label   time
  2014-04-06  A   12:05:56
  2014-04-06  A   23:02:32
  2014-04-06  B   8:39:25
  2014-04-06  B   12:36:37
  2014-04-06  C   12:20:43
  2014-04-06  C   12:56:44
  2014-04-06  D   20:52:22
  2014-04-06  E   22:25:30
  2014-04-06  F   12:16:15
  2014-04-06  F   12:31:09
  2014-04-06  F   17:12:06
  2014-04-06  G   7:48:32
  2014-04-06  H   17:58:11
  2014-04-05  I   12:05:56
  2014-04-05  I   20:02:32
  2014-04-05  I   23:57:32
  2014-04-05  J   12:36:37
  2014-04-05  K   12:20:43
  2014-04-05  L   12:56:44
  2014-04-05  M   20:52:22
  2014-04-05  M   22:25:30
  2014-04-05  N   12:16:15
  2014-04-05  O   12:31:09
  2014-04-05  O   17:12:06
  2014-04-05  P   7:48:32
  2014-04-05  Q   17:58:11
  2014-04-06  R   1:05:56
  2014-04-06  R   5:02:32
  2014-04-06  R   8:39:25
  2014-04-06  R   12:36:37
  2014-04-06  S   12:20:43
  2014-04-06  S   12:56:44
  2014-04-06  S   20:52:22
  2014-04-06  T   22:25:30
  2014-04-06  U   12:16:15
  2014-04-06  V   12:31:09
  2014-04-06  W   3:48:32
  2014-04-06  W   7:48:32
  2014-04-06  W   17:58:11
  </pre>
  
  <p>I'm trying to create a view with this output.</p>
  
  <pre>
  date    label   time    status
  2014-04-06  A   12:05:56    Repeat
  2014-04-06  A   23:02:32    Unique
  2014-04-06  B   8:39:25 Repeat
  2014-04-06  B   12:36:37    Unique
  2014-04-06  C   12:20:43    Repeat
  2014-04-06  C   12:56:44    Unique
  2014-04-06  D   20:52:22    Unique
  2014-04-06  E   22:25:30    Unique
  2014-04-06  F   12:16:15    Repeat
  2014-04-06  F   12:31:09    Repeat
  2014-04-06  F   17:12:06    Unique
  2014-04-06  G   7:48:32 Unique
  2014-04-06  H   17:58:11    Unique
  2014-04-05  I   12:05:56    Repeat
  2014-04-05  I   20:02:32    Repeat
  2014-04-05  I   23:57:32    Unique
  2014-04-05  J   12:36:37    Unique
  2014-04-05  K   12:20:43    Unique
  2014-04-05  L   12:56:44    Unique
  2014-04-05  M   20:52:22    Repeat
  2014-04-05  M   22:25:30    Unique
  2014-04-05  N   12:16:15    Unique
  2014-04-05  O   12:31:09    Repeat
  2014-04-05  O   17:12:06    Unique
  2014-04-05  P   7:48:32 Unique
  2014-04-05  Q   17:58:11    Unique
  2014-04-06  R   1:05:56 Repeat
  2014-04-06  R   5:02:32 Repeat
  2014-04-06  R   8:39:25 Repeat
  2014-04-06  R   12:36:37    Unique
  2014-04-06  S   12:20:43    Repeat
  2014-04-06  S   12:56:44    Repeat
  2014-04-06  S   20:52:22    Unique
  2014-04-06  T   22:25:30    Unique
  2014-04-06  U   12:16:15    Unique
  2014-04-06  V   12:31:09    Unique
  2014-04-06  W   3:48:32 Repeat
  2014-04-06  W   7:48:32 Repeat
  2014-04-06  W   17:58:11    Unique
  </pre>
  
  <p>The criteria for the <code>status</code> column will be like this.</p>
  
  <p>I wanted to loop in each row based on the <code>label</code> and <code>time</code> column criteria the status column is derived.</p>
  
  <p>Suppose the 1st row of label = 2nd row of label and the difference of time for 2nd row and 1st row is greater 24:00:00 then it must be yes else no.</p>
  
  <p>I do it like this in excel.</p>
  
  <p><code>=IF(AND(B2=B3,C3-C2&gt;1),"Yes","No")</code></p>
  
  <p>I'm new to PostgreSQL and database.</p>
  
  <p>Any suggestions or help will be very much helpful in passing through this.</p>
  
  <p>Thanks in advance.</p>