title: Generate id row for a view with grouping
body: <p>I'm trying to create a view with row numbers like so:</p>
  
  <pre><code>create or replace view daily_transactions as
  select 
      generate_series(1, count(t)) as id,        
      t.ic,
      t.bio_id,
      t.wp,    
      date_trunc('day', t.transaction_time)::date transaction_date, 
      min(t.transaction_time)::time time_in, 
      w.start_time wp_start,    
      w.start_time - min(t.transaction_time)::time in_diff,    
      max(t.transaction_time)::time time_out,     
      w.end_time wp_end,    
      max(t.transaction_time)::time - w.end_time out_diff,     
      count(t) total_transactions,
      calc_att_status(date_trunc('day', t.transaction_time)::date,
                      min(t.transaction_time)::time,
                      max(t.transaction_time)::time,
                      w.start_time, w.end_time ) status        
  from transactions t
  left join wp w  on (t.wp = w.wp_name)
  group by ic, bio_id, t.wp, date_trunc('day', transaction_time),
           w.start_time, w.end_time;
  </code></pre>
  
  <p>I ended up with duplicate rows. <code>SELECT DISTINCT</code> doesn't work either. Any ideas?</p>
  
  <p>Transaction Table:</p>
  
  <pre><code>create table transactions(
      id serial primary key,    
      ic text references users(ic),
      wp text references wp(wp_name),
      serial_no integer,    
      bio_id integer,
      node integer,
      finger integer,
      transaction_time timestamp,    
      transaction_type text,        
      transaction_status text        
   );
  </code></pre>
  
  <p>WP table:</p>
  
  <pre><code>create table wp(
      id serial unique,   
      wp_name text primary key,
      start_time time,
      end_time time,
      description text,
      status text    
  );
  </code></pre>
  
  <p>View Output:</p>
  
  <p><img src="https://i.stack.imgur.com/tCpyh.png" alt="View Output"></p>