>Muito obrigado, Antonio!
>I confess that I gave a sloppy description of the problem.
>Please ignore the second column (Bore).
>I am looking for the largest difference of depth in two consecutive records. I recieve these data from a measuring device potentially in more than one csv files which I append into that table. Primarily the raw data are not even sorted by depth, so first of all I may have to "translate" these data into an ordered table with an additive column "Position" and then perform your suggestion with the modification of joining the table against itself on D1.position = D2.position +1. (see new attachment)
>Would you agree with that?
>
>Best regards
Eugen,
If I got your requirements right, and since your concept of "consecutive records" seems based on depth values, you may skip the depth ordering and record positioning steps and query the source directly as it comes after being concatenated:
SELECT TOP 1 ABS(D1.Depth - D2.Depth) AS DepthDifference, D1.Depth, D2.Depth ;
FROM csvData D1 ;
INNER JOIN csvData D2 ON D2.Depth > D1.Depth ;
WHERE D2.Depth = (SELECT MIN(Dt.Depth) FROM csvData Dt WHERE Dt.Depth > D1.Depth) ;
ORDER BY 1 DESC
This will return 0.190 between depths 5.560 and 5.570.
----------------------------------
António Tavares Lopes