Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Data Bases > Pgsql Sql > Difference in c...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 1 of 9 Topic 3461 of 3596
Post > Topic >>

Difference in columns

by magawake@[EMAIL PROTECTED] ("Mag Gam") May 11, 2008 at 01:37 PM

------=_Part_9148_30830788.1210527475753
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

Hi All,

I have a view that generates output similar to this.

select * from foo.view;

       ts          | size
-------------------+-----
 2002-03-16        | 11
 2002-03-17        | 16
 2002-03-18        | 18
 2002-03-19        | 12

I am trying to find the difference between the size column. So the desired
output would be

       ts          | size| Diff
-------------------+-----+------
 2002-03-16        | 11  | 0
 2002-03-17        | 15  | 4
 2002-03-18        | 18  | 3
 2002-03-19        | 12  | -6


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.

Any thoughts about this?

TIA

------=_Part_9148_30830788.1210527475753
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

Hi All,<br><br>I have a view that generates output similar to
this.<br><br>select * from foo.view;<br><br><pre class="PROGRAMLISTING">  
    ts          | size<br>-------------------+-----<br> 2002-03-16        |
11 <br> 2002-03-17        | 16 <br>
 2002-03-18        | 18<br>&nbsp;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>&nbsp;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> 

------=_Part_9148_30830788.1210527475753--
 




 9 Posts in Topic:
Difference in columns
magawake@[EMAIL PROTECTED  2008-05-11 13:37:52 
Re: Difference in columns
chestercyoung@[EMAIL PROT  2008-05-11 10:54:38 
Re: Difference in columns
singh.gurjeet@[EMAIL PROT  2008-05-11 23:25:06 
Re: Difference in columns
depesz@[EMAIL PROTECTED]   2008-05-11 20:11:42 
Re: Difference in columns
craig@[EMAIL PROTECTED]   2008-05-12 02:17:45 
Re: Difference in columns
singh.gurjeet@[EMAIL PROT  2008-05-12 00:06:12 
Re: Difference in columns
tgl@[EMAIL PROTECTED] (T  2008-05-11 14:58:02 
Re: Difference in columns
craig@[EMAIL PROTECTED]   2008-05-12 03:58:56 
Re: Difference in columns
magawake@[EMAIL PROTECTED  2008-05-11 20:58:28 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan13V112 Thu Jul 24 5:04:53 CDT 2008.