In a SQL query with Visual FoxPro, how can a record access the information in the previous record?

0

I am working with an application that is built with Visual FoxPro 6.0 , at this moment I need to make a query that allows a record within a SELECT to obtain information from the immediately previous record to perform a calculation.

The calculation is simply between date fields, which should allow a record to determine how much time has passed with respect to the same field as the previous record.

The query I am looking for is something similar to the following (simply an idea):

SELECT 
    fila,
    fecha, 
    (fecha - fecha<del registro anterior>) as tiempo_transcurrido
FROM
    tabla

And the result that I hope to obtain is the following:

fila    fecha                  tiempo_tiempo_transcurrido
1       2017-04-07 00:00:00    0
2       2017-04-07 00:00:10    10
3       2017-04-07 00:00:15    5
4       2017-04-07 00:01:00    45

NOTE: I can not use own functions of SQL Server , ORACLE or MySQL because I am working on the engine of Visual FoxPro 6.0

    
asked by Weimar Yamit Moreno Perez 07.04.2017 в 15:58
source

2 answers

0

I have solved the problem by doing the following

I sort my rows by the date field and then I list them to pass them to CURSOR :

SELECT RECNO() Fila, * ;
FROM ;
( ;
    SELECT fecha FROM tabla ORDER BY fecha ;
) as subquery ;
INTO CURSOR datos_enumerados

Then I use the CURSOR to make the comparisons I need:

SELECT datos1.*, ROUND((datos1.fecha - datos2.fecha) / 60, 2) as minutos ;
FROM ;
    datos_enumerados as datos1 LEFT JOIN datos_enumerados as datos2 ;
    ON datos1.Fila = (datos2.Fila + 1)
    
answered by 07.04.2017 / 19:18
source
0

I found your answer excellent in: Login to using the active directory in ASP.NET However, my case goes a little further. Instead of using a login window, I want to read the user already logged in.

I have tried to read the user with my application but my application runs on a web server and the user of that server reads it and not the local user of the browser.

In other words: If the user already logged in on windows, I do not want him to log in again on the web server, I do not really want him to take the domain or the user, I want him to read me the groups he belongs to or Let me have the group that I have to see if the user belongs to that group.

    
answered by 12.10.2017 в 17:26