Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
 Polido
		
			Polido
		
		
		
		
		
		
		
		
	
			
		
		
			
					
		Hello everyone!
I've tried to search if this was already solved on the forum but without luck.
I need to get the location from the last same 'vin' (vehicle identification number).
Right now I have the following: IF(vin = PEEK(vin),Peek(location)) AS peekLocation
But if vin <> peek(vin) then I don't know how to fetch the next most recent vin.
See the attached image to see the real data.
Thanks in advance!
 
					
				
		
 Thiago_Justen_
		
			Thiago_Justen_
		
		
		
		
		
		
		
		
	
			
		
		
			
					
		Hi there,
May be this:
YourDB_Table:
Load
Your_DB_Fields
From Your_DB;
Your_Table:
Load
Your_Fields,
If ( vin = Previous(vin) , Previous(location), location) As Last_Location
Resident YourDB_Table
Order By
vin, YOUR_DATE_FIELD
Asc;
Drop Table YourDB_Table;
So, as @MarcoWedel said, you should be able to order resident table by vin and datetime field ascending (from older to newer values).
Regards,
 
					
				
		
 MarcoWedel
		
			MarcoWedel
		
		
		
		
		
		
		
		
	
			
		
		
			
					
		you have to order by vin during load.
Please post some data as well as your expected result.
Thanks
Marco
 
					
				
		
 Thiago_Justen_
		
			Thiago_Justen_
		
		
		
		
		
		
		
		
	
			
		
		
			
					
		Hi there,
May be this:
YourDB_Table:
Load
Your_DB_Fields
From Your_DB;
Your_Table:
Load
Your_Fields,
If ( vin = Previous(vin) , Previous(location), location) As Last_Location
Resident YourDB_Table
Order By
vin, YOUR_DATE_FIELD
Asc;
Drop Table YourDB_Table;
So, as @MarcoWedel said, you should be able to order resident table by vin and datetime field ascending (from older to newer values).
Regards,
 Polido
		
			Polido
		
		
		
		
		
		
		
		
	
			
		
		
			
					
		Thank you very much for the help, it works!
Cheers 🙂
