MySQL Forums
Forum List  »  Spanish

Fecha de comparación de SQL en Mysql
Posted by: Jose carlos carlospaest
Date: February 25, 2022 04:06PM

Buenas tardes

Necesito comparar la columna create_time, analizando por nombre (bloquear) min (create_time)> nombre (desbloquear) min (create_time).

A medida que los datos más pequeños tienen una identificación más pequeña

tabla:

CREATE TABLE `agents` (
`tn` INT NOT NULL,
`name` varchar(20),
`create_time` date,
`id` int
);


INSERT INTO `agents` (`tn`,`name`,`create_time`,`id`) VALUES ('10541006','Lock','2022-02-07 10:06:15',15391997);
INSERT INTO `agents` (`tn`,`name`,`create_time`,`id`) VALUES ('10541006','Lock','2022-02-10 10:54:20',15457008);
INSERT INTO `agents` (`tn`,`name`,`create_time`,`id`) VALUES ('10541006','Lock','2022-02-10 11:03:24',15457319);
INSERT INTO `agents` (`tn`,`name`,`create_time`,`id`) VALUES ('10541006','Lock','2022-02-11 08:09:54',15471174);
INSERT INTO `agents`(`tn`,`name`,`create_time`,`id`) VALUES ('10541006','Lock','2022-02-11 08:52:21',15472333);
INSERT INTO `agents` (`tn`,`name`,`create_time`,`id`) VALUES ('10541006','Unlock','2022-02-07 16:33:01',15402391);
INSERT INTO `agents` (`tn`,`name`,`create_time`,`id`) VALUES ('10541006','Unlock','2022-02-10 10:54:32',15457012);
INSERT INTO `agents` (`tn`,`name`,`create_time`,`id`) VALUES ('10541006','Unlock','2022-02-10 18:03:25',15467979);
INSERT INTO `agents` (`tn`,`name`,`create_time`,`id`) VALUES ('10541006','Unlock','2022-02-11 08:10:56',15471424);
INSERT INTO `agents` (`tn`,`name`,`create_time`,`id`) VALUES ('10541006','Unlock','2022-02-11 17:27:34',15483956);


tn nombre create_time id

10541006 Bloqueo 2022-02-07 10:06:15 15391997
10541006 Desbloquear 2022-02-07 16:33:01 15402391
10541006 Bloqueo 2022-02-10 10:54:20 15457008
10541006 Desbloquear 2022-02-10 10:54:32 15457012
10541006 se cuelga 2022-02-10 11:03:24 15457319
10541006 Desbloquear 2022-02-10 18:03:25 15467979
10541006 se cuelga 2022-02-11 08:09 :54 15471174
10541006 Desbloquear 2022-02-11 08:10:56 15471424
10541006 Bloque 2022-02-11 08:52:21 15472333
10541006 Desbloquear 2022-02-11 17:27:34 15483956

Salida:

tn create_time_lock create_time_unlock

10541006 2022-02-07 10:06:15 2022-02-07 16:33:01
10541006 2022-02-10 10:54:20 2022-02-10 10:54:32
10541006 2022-02-10 11:03:24 2022-02-10 18:03:25
10541006 2022-02-11 08:09:54 2022-02-11 08:10 :56
10541006 2022-02-11 08:52:21 2022-02-11 17:27:34

Options: ReplyQuote


Subject
Views
Written By
Posted
Fecha de comparación de SQL en Mysql
216
February 25, 2022 04:06PM


Sorry, only registered users may post in this forum.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.