Home >Database >Mysql Tutorial >mysql-关于MySQL连续为0检查的问题

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

WBOY
WBOYOriginal
2016-06-06 09:40:051184browse

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,
)

<code>[cbrq] [nvarchar](19) NULL,[ysl] [int] NULL,</code>

)

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

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn