sql query question ?

From: Trilok Kumar <trilokumar(at)yahoo(dot)co(dot)uk>
To: pgsql-sql(at)postgresql(dot)org
Subject: sql query question ?
Date: 2007-12-29 10:52:45
Message-ID: 238306.65674.qm@web27208.mail.ukl.yahoo.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

Hi All,

I have a table called

vehicle_duty_cycle_summary

vehicle_master_id | starting_odometer |
ending_odometer | login_time |
logout_time
-------------------+-------------------+-----------------+----------------------------+----------------------------

4 | 53379.00 | 53504.00 | 2006-12-19
16:19:16.584547 | 2006-12-20 07:12:57.716907
4 | 51310.00 |
51457.00 | 2006-12-05 16:04:51.585441 | 2006-12-06
07:18:10.251535
4 | 42411.00 |
42411.00 | 2006-09-14 16:03:49.541442 | 2006-09-15
08:24:41.308339
4 | 54012.00 |
54146.00 | 2006-12-25 16:14:31.313728 | 2006-12-26
07:05:55.82487
4 | 43071.00 |
43181.00 | 2006-09-21 11:24:43.466766 | 2006-09-22
07:10:09.362792
4 | 51208.00 |
51305.00 | 2006-12-04 16:14:14.600105 | 2006-12-05
08:03:38.139832
4 | 50235.00 |
50370.00 | 2006-11-27 15:55:48.866925 | 2006-11-28
07:27:25.898991
4 | 53231.00 |
53362.00 | 2006-12-18 16:06:42.764133 | 2006-12-19
07:06:03.450072
4 | 52656.00 |
52818.00 | 2006-12-13 16:03:47.189303 | 2006-12-14
07:59:11.463733
4 | 50801.00 |
50880.00 | 2006-12-02 16:03:55.666321 | 2006-12-03
06:53:21.433746
9 | 85360.00 |
85493.00 | 2007-06-10 07:17:12.330974 | 2007-06-10
22:11:04.422656
9 | 78009.00 |
78042.00 | 2007-03-12 17:53:18.794001 | 2007-03-12
20:42:39.439647
9 | 84529.00 |
84679.00 | 2007-06-01 06:42:09.306306 | 2007-06-01
20:35:54.317172
9 | 78058.00 |
78149.00 | 2007-03-13 10:08:48.696709 | 2007-03-13
21:50:31.136412
9 | 86506.00 |
86595.00 | 2007-06-21 09:28:40.504082 | 2007-06-21
23:15:41.862292
9 | 78155.00 |
78239.00 | 2007-03-14 09:32:58.512817 | 2007-03-14
20:58:24.36362
9 | 84894.00 |
85012.00 | 2007-06-04 07:59:00.896969 | 2007-06-04
18:42:13.791974
9 | 78435.00 |
78494.00 | 2007-03-16 07:48:23.626402 | 2007-03-16
21:39:09.479043
9 | 83992.00 |
84045.00 | 2007-05-25 07:25:20.462928 | 2007-05-25
21:23:43.697577
9 | 78506.00 |
78595.00 | 2007-03-17 08:01:06.003564 | 2007-03-17
19:48:32.383689
9 | 85493.00 |
85640.00 | 2007-06-11 06:58:03.052538 | 2007-06-11
22:56:13.134053
9 | 78279.00 |
78395.00 | 2007-03-15 08:00:58.198265 | 2007-03-15
21:39:00.052173

I would like to compute the following on this table.

Idle time of vehicel=(ending_odometer reading of the
previous day -
starting_odometer reading of the present day) for
every vehicle

can anybody help me this issue.

Thanks in advance.

Trilok

__________________________________________________________
Sent from Yahoo! Mail - a smarter inbox http://uk.mail.yahoo.com

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message Shane Ambler 2007-12-29 17:22:05 Re: sql query question ?
Previous Message Pavel Stehule 2007-12-29 07:29:22 Re: PL/pgsql: function passing argument to IN operator