title: PostgreSQL query with conditional empty values depending on preceding rows
body: <p>I am working on a postgresql query that i am not sure how to produce the output.</p>
  
  <p>Lets say i have a sql query whose output i want is </p>
  
  <pre><code>         name    date     visit_number  visit
            x    2011-01-01     123         ??   (value i want=1)
            y    2011-01-01     123         ??   (value i want=empty)
            a    2011-02-02     345         ??   (value i want=1) 
            b    2011-02-02     345         ??    (empty)
            c    2011-02-02     345         ??     (empty)
  </code></pre>
  
  <p>currently my sql query contains all the values except the last column visit. I want the visit column to work this way...if visit_number contains same value for multiple rows, i want the column visit to show the value 1 for the first row and just null or empty for the remaining rows where the visit_number is the same. How do i do that???</p>
  
  <p>i could write the sample query in any way.it could simply be :</p>
  
  <pre><code>    select name,date,visit_number from sometable order by date;
  </code></pre>
  
  <p>I am using postgres 8.1 version.</p>
  
  <p>Thanks</p>