Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to get the next field

Status
Not open for further replies.

JPozo

Technical User
Jun 8, 2002
13
PE
Dear Friends,
I have a dayly file like this:
Field_1
0
3
6
10
12
20
0
5
15

And I would like to get:

Field_1 Field_2 Last_1
0 3 3
3 6 3
6 10 4
10 12 2
12 20 8
20 0 4
0 5 5
5 15 10
15 9


Is there any way to do this, I was thinking that maybe there is some function to get the value form next field, like GetNext()

Select
Filed_1,
GetNext(Field_1) as Field_2,
if(GetNext(Filed_1) > Field_1, GetNext(Filed_1) - Field_1, 24 - Field_1) as Last_1
From
Dayly_File

Best Regards,
Javier Pozo
 
How are the Field_1 ordered ?
i.e. how do you know that 0 is after 20 and before 5 ?

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
PHV:
The Field_1 takes the actual hour (between 0 and 24), for example:
- First event at 20 hours
- Second event at 0 hours: there´s always a 0, crew change
- Third event at 5 hours. and so on
Best Regards,
Javier
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top