SQL每日一题(20230831)

2024-04-25 09:02:37 浏览数 (1)

题目

有如下1张表G0831

希望得到如下结果(根据TransType取每道OprSeq的开始与结束时间,其中,开始-换班是一组,开始-结束是一组)

测试语句

代码语言:javascript复制
Create table G0831 (
TransType varchar(22),
OprSeq int,
OpCode varchar(24),
TransTime varchar(34)
);

INSERT INTO G0831 VALUES('开始',10,'NF21','2019-11-30 14:06');
INSERT INTO G0831 VALUES('换班',10,'NF21','2019-11-30 14:09');
INSERT INTO G0831 VALUES('开始',10,'NF21','2019-11-30 14:10');
INSERT INTO G0831 VALUES('结束',10,'NF21','2019-11-30 14:13');
INSERT INTO G0831 VALUES('开始',20,'NF22','2019-11-30 14:15');
INSERT INTO G0831 VALUES('结束',20,'NF22','2019-11-30 14:16');
INSERT INTO G0831 VALUES('开始',30,'NF24','2019-11-30 14:17');
INSERT INTO G0831 VALUES('结束',30,'NF24','2019-11-30 14:20');

0 人点赞