Rumah >pangkalan data >tutorial mysql >mysql-关于MySQL连续为0检查的问题

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

WBOY
WBOYasal
2016-06-06 09:40:051168semak imbas

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

Kenyataan:
Kandungan artikel ini disumbangkan secara sukarela oleh netizen, dan hak cipta adalah milik pengarang asal. Laman web ini tidak memikul tanggungjawab undang-undang yang sepadan. Jika anda menemui sebarang kandungan yang disyaki plagiarisme atau pelanggaran, sila hubungi admin@php.cn