Difference in columns - Mailing list pgsql-sql

From Mag Gam
Subject Difference in columns
Date
Msg-id 1cbd6f830805111037m488f7051i7924060a1640fff4@mail.gmail.com
Whole thread Raw
Responses Re: Difference in columns  (chester c young <chestercyoung@yahoo.com>)
Re: Difference in columns  ("Gurjeet Singh" <singh.gurjeet@gmail.com>)
Re: Difference in columns  (hubert depesz lubaczewski <depesz@depesz.com>)
Re: Difference in columns  (Craig Ringer <craig@postnewspapers.com.au>)
Re: Difference in columns  (Craig Ringer <craig@postnewspapers.com.au>)
List pgsql-sql
Hi All,<br /><br />I have a view that generates output similar to this.<br /><br />select * from foo.view;<br /><br
/><preclass="PROGRAMLISTING">       ts          | size<br />-------------------+-----<br /> 2002-03-16        | 11 <br
/>2002-03-17        | 16 <br />2002-03-18        | 18<br /> 2002-03-19        | 12 
 
<br /></pre>I am trying to find the difference between the size column. So the desired output would be<br /><br /><pre
class="PROGRAMLISTING">      ts          | size| Diff<br />-------------------+-----+------<br /> 2002-03-16        |
11 | 0<br />2002-03-17        | 15  | 4<br /> 2002-03-18        | 18  | 3<br /> 2002-03-19        | 12  | -6<br
/></pre><br/>I need the first column to be 0, since it will be 11-11. The second colum is 15-11. The third column is
18-15.The fourth column is 12-18. <br /><br />Any thoughts about this?<br /><br />TIA<br /> 

pgsql-sql by date:

Previous
From: "Christian Kindler"
Date:
Subject: Re: execute plpgsl like "normal" sql
Next
From: chester c young
Date:
Subject: Re: Difference in columns