当前位置:Gxlcms > mysql > mysql-关于MySQL连续为0检查的问题

mysql-关于MySQL连续为0检查的问题

时间:2021-07-01 10:21:17 帮助过:29人阅读

mysql

CREATE TABLE [dbo].Jqfk NOT NULL,
[yhh] char NULL,CREATE TABLE [dbo].Jqfk NOT NULL,
[yhh] char NULL,
[cbrq] nvarchar NULL,
[ysl] [int] NULL,
)

[cbrq] [nvarchar](19) NULL,[ysl] [int] NULL,

)

INSERT INTO jqfk VALUES ('B173022031201','2015-01-08 10:12:30',0);
INSERT INTO jqfk VALUES ('B211001024011','2015-01-08 10:46:13',13);
INSERT INTO jqfk VALUES ('B211001024012','2015-01-08 10:46:13',0);
INSERT INTO jqfk VALUES ('B211001024013','2015-01-08 10:46:13',3);
INSERT INTO jqfk VALUES ('B211001024014','2015-01-08 10:46:13',0);

INSERT INTO jqfk VALUES ('B173022031201','2015-02-08 10:46:13',0);
INSERT INTO jqfk VALUES ('B211001024011','2015-02-08 10:46:13',0);
INSERT INTO jqfk VALUES ('B211001024012','2015-02-08 10:46:13',13);
INSERT INTO jqfk VALUES ('B211001024013','2015-02-08 10:46:13',11);
INSERT INTO jqfk VALUES ('B211001024014','2015-02-08 10:46:13',0);

INSERT INTO jqfk VALUES ('B173022031201','2015-03-08 10:46:13',0);
INSERT INTO jqfk VALUES ('B211001024011','2015-03-08 10:46:13',0);
INSERT INTO jqfk VALUES ('B211001024012','2015-03-08 10:46:13',0);
INSERT INTO jqfk VALUES ('B211001024013','2015-03-08 10:46:13',0);
INSERT INTO jqfk VALUES ('B211001024014','2015-03-08 10:46:13',0);

INSERT INTO jqfk VALUES ('B173022031201','2015-04-08 10:46:13',13);
INSERT INTO jqfk VALUES ('B211001024011','2015-04-08 10:46:13',0);
INSERT INTO jqfk VALUES ('B211001024012','2015-04-08 10:46:13',12);
INSERT INTO jqfk VALUES ('B211001024013','2015-04-08 10:46:13',0);
INSERT INTO jqfk VALUES ('B211001024014','2015-04-08 10:46:13',0);

我需要最后一次为0,且之后按时间倒序排序为0 的次数。其实需要的是最近一次为0的用户,他最近为0次数。

结果

1 B211001024014 4
2 B211001024011 3
3 B211001024013 2

人气教程排行