Hola, tengo una consulta, que forma parte de un procedimiento almacenado, ahorita estoy analizando la consulta, y me regresa registros de una tabla, todo lo demas son validaciones de relaciones de tablas, mm algo asi..
consulta sql:
SELECT TOP 1000 RES.Id_Senal, RES.Fecha_Registro, RES.Valor
FROM (SELECT DISTINCT VALORES_ANALOGICOS.Id_Senal, VALORES_ANALOGICOS.Fecha_Registro,
VALORES_ANALOGICOS.Valor FROM VALORES_ANALOGICOS
INNER JOIN VARIABLES_C01 ON VALORES_ANALOGICOS.Id_Senal = VARIABLES_C01.Id_Senal
INNER JOIN TIPOS_DE_SISTEMAS ON VARIABLES_C01.No_Sistema = TIPOS_DE_SISTEMAS.No_Sistema
WHERE (TIPOS_DE_SISTEMAS.No_Central IN ('1') )
AND (CAST(VALORES_ANALOGICOS.Fecha_Registro AS DATETIME)
BETWEEN '02/05/2007 10:00:00' and '02/05/2007 15:00:00')
AND VALORES_ANALOGICOS.Id_Senal IN ('A01U1040','l01u1040')
UNION SELECT DISTINCT VALORES_BINARIOS.Id_Senal, VALORES_BINARIOS.Fecha_Registro,
VALORES_BINARIOS.Valor FROM VARIABLES_C01 INNER JOIN TIPOS_DE_SISTEMAS
ON VARIABLES_C01.No_Sistema = TIPOS_DE_SISTEMAS.No_Sistema INNER JOIN
VALORES_BINARIOS ON VARIABLES_C01.Id_Senal = VALORES_BINARIOS.Id_Senal
WHERE (TIPOS_DE_SISTEMAS.No_Central IN ('1') )
AND (CAST(VALORES_BINARIOS.Fecha_Registro AS DATETIME)
BETWEEN '02/05/2007 10:00:00' and '02/05/2007 12:00:00')
AND VALORES_BINARIOS.Id_Senal IN ('A01U1040','l01u1040') )
RES ORDER BY RES.Fecha_Registro, RES.Id_Senal
Resultados :
A01U1040 2007-05-02 12:20:32.000 59.969999084472668
A01U1040 2007-05-02 12:20:41.000 59.990001678466797
A01U1040 2007-05-02 12:20:52.000 59.9400016784668
A01U1040 2007-05-02 12:21:02.000 59.930001678466802
A01U1040 2007-05-02 12:21:12.000 59.960001678466803
A01U1040 2007-05-02 12:21:22.000 59.920001678466804
A01U1040 2007-05-02 12:21:52.000 59.900001678466801
A01U1040 2007-05-02 12:22:02.000 59.910001678466799
A01U1040 2007-05-02 12:22:12.000 59.910001678466799
A01U1040 2007-05-02 12:22:23.000 59.930001678466802
A01U1040 2007-05-02 12:22:33.000 59.930001678466802
A01U1040 2007-05-02 12:22:43.000 59.9400016784668
A01U1040 2007-05-02 12:22:54.000 59.910001678466799
A01U1040 2007-05-02 12:23:05.000 59.920001678466797
A01U1040 2007-05-02 12:23:13.000 59.910001678466799
A01U1040 2007-05-02 12:23:21.000 59.920001678466797
A01U1040 2007-05-02 12:23:33.000 59.950001678466798
A01U1040 2007-05-02 12:23:42.000 59.920001678466797
A01U1040 2007-05-02 12:23:51.000 59.910001678466799
A01U1040 2007-05-02 12:24:02.000 59.900001678466801
A01U1040 2007-05-02 12:24:12.000 59.890001678466803
A01U1040 2007-05-02 12:24:23.000 59.930001678466802
A01U1040 2007-05-02 12:24:31.000 59.930001678466802
A01U1040 2007-05-02 12:24:42.000 59.970001678466801
A01U1040 2007-05-02 12:24:53.000 60.000001678466802
A01U1040 2007-05-02 12:25:02.000 60.020001678466805
A01U1040 2007-05-02 12:25:13.000 60.020001678466805
A01U1040 2007-05-02 12:25:22.000 60.020001678466805
A01U1040 2007-05-02 12:25:33.000 60.010001678466807
A01U1040 2007-05-02 12:25:42.000 59.990001678466804
A01U1040 2007-05-02 12:25:52.000 59.970001678466801
A01U1040 2007-05-02 12:26:03.000 59.980001678466799
A01U1040 2007-05-02 12:26:23.000 59.980001678466799
A01U1040 2007-05-02 12:26:33.000 59.970001678466801
A01U1040 2007-05-02 12:26:43.000 59.980001678466799
A01U1040 2007-05-02 12:27:02.000 59.990001678466797
A01U1040 2007-05-02 12:27:12.000 60.020001678466798
A01U1040 2007-05-02 12:27:22.000 60.000001678466795
A01U1040 2007-05-02 12:27:32.000 60.020001678466798
A01U1040 2007-05-02 12:27:42.000 60.020001678466798
A01U1040 2007-05-02 12:27:52.000 60.000001678466795
A01U1040 2007-05-02 12:28:02.000 59.970001678466794
A01U1040 2007-05-02 12:28:12.000 59.940001678466793
A01U1040 2007-05-02 12:28:32.000 59.950001678466791
A01U1040 2007-05-02 12:28:54.000 59.930001678466787
A01U1040 2007-05-02 12:29:01.000 59.900001678466786
A01U1040 2007-05-02 12:29:12.000 59.920001678466789
A01U1040 2007-05-02 12:29:24.000 59.930001678466787
A01U1040 2007-05-02 12:29:32.000 59.910001678466784
A01U1040 2007-05-02 12:29:42.000 59.930001678466787
A01U1040 2007-05-02 12:29:54.000 59.940001678466786
A01U1040 2007-05-02 12:30:06.000 59.930001678466787
A01U1040 2007-05-02 12:30:12.000 59.920001678466789
A01U1040 2007-05-02 12:30:42.000 59.920001678466789
A01U1040 2007-05-02 12:30:52.000 59.910001678466791
A01U1040 2007-05-02 12:31:02.000 59.920001678466789
A01U1040 2007-05-02 12:31:15.000 59.920001678466789
A01U1040 2007-05-02 12:31:24.000 59.930001678466787
A01U1040 2007-05-02 12:31:32.000 59.940001678466786
A01U1040 2007-05-02 12:31:42.000 59.990001678466783
A01U1040 2007-05-02 12:31:54.000 59.980001678466785
A01U1040 2007-05-02 12:32:05.000 59.970001678466787
A01U1040 2007-05-02 12:32:12.000 59.970001678466787
A01U1040 2007-05-02 12:32:23.000 59.99000167846679
A01U1040 2007-05-02 12:32:32.000 60.000001678466788
A01U1040 2007-05-02 12:32:42.000 60.000001678466788
A01U1040 2007-05-02 12:32:52.000 60.000001678466788
A01U1040 2007-05-02 12:33:15.000 59.970001678466787
A01U1040 2007-05-02 12:33:32.000 59.99000167846679
A01U1040 2007-05-02 12:33:42.000 60.000001678466788
A01U1040 2007-05-02 12:34:12.000 59.960001678466789
A01U1040 2007-05-02 12:34:21.000 59.960001678466789
A01U1040 2007-05-02 12:34:32.000 59.940001678466786
A01U1040 2007-05-02 12:34:53.000 59.910001678466784
A01U1040 2007-05-02 12:35:03.000 59.900001678466786
A01U1040 2007-05-02 12:35:13.000 59.900001678466786
A01U1040 2007-05-02 12:35:33.000 59.900001678466786
A01U1040 2007-05-02 12:35:44.000 59.910001678466784
A01U1040 2007-05-02 12:35:54.000 59.930001678466787
A01U1040 2007-05-02 12:36:03.000 59.930001678466787
A01U1040 2007-05-02 12:36:14.000 59.920001678466789
A01U1040 2007-05-02 12:36:22.000 59.920001678466789
A01U1040 2007-05-02 12:36:33.000 59.950001678466791
A01U1040 2007-05-02 12:36:42.000 59.940001678466793
A01U1040 2007-05-02 12:37:04.000 59.940001678466793
A01U1040 2007-05-02 12:37:13.000 59.960001678466796
A01U1040 2007-05-02 12:37:21.000 59.950001678466798
A01U1040 2007-05-02 12:37:33.000 59.9400016784668
A01U1040 2007-05-02 12:37:43.000 59.930001678466802
A01U1040 2007-05-02 12:38:04.000 59.910001678466799
A01U1040 2007-05-02 12:38:13.000 59.910001678466799
A01U1040 2007-05-02 12:38:23.000 59.900001678466801
A01U1040 2007-05-02 12:38:32.000 59.930001678466802
A01U1040 2007-05-02 12:38:46.000 59.900001678466801
A01U1040 2007-05-02 12:38:51.000 59.890001678466803
A01U1040 2007-05-02 12:39:01.000 59.910001678466806
A01U1040 2007-05-02 12:39:12.000 59.910001678466806
A01U1040 2007-05-02 12:39:22.000 59.900001678466808
A01U1040 2007-05-02 12:39:32.000 59.900001678466808
A01U1040 2007-05-02 12:39:52.000 59.900001678466808
Ahora si se dan cuenta, esa consulta me regresa registros, de una misma variable (A01U1040) que realmente son mas, pero bueno, esos registros, son cambios que tuvo esa variable, y cada reglon se registra cada 10 segundos, ahora por ejemplo si yo quisiera solo, los registros ke pertenece a un minuto, es decir ahora ke no se vean todos los registros con un margen de 10 segundos, si no de un minuto, me explico ???
me pidieron, con valor instantaneo, ke es el valor normal
valor promedio :S
valor maximo :S
Es decir tengo q hacer una seleccion, de esos registros, komo puedo decirle ke solo me mand los registros ke cambiaron en un minuto
gracias, saludos