Home > Database > Mysql Tutorial > mysql实现ROW_NUMBER() sql 排名

mysql实现ROW_NUMBER() sql 排名

WBOY
Release: 2016-06-07 14:57:38
Original
1614 people have browsed it

mysql实现某个时间数据段统计排名 MySQL select *,(@rowNo:=@rowNo+1) as pmfrom(select id,sum(value) as sumValuefrom youTable as pwhere p.date BETWEEN DATE_FORMAT('2014-06-01','%Y-%m-%d 00:00:00') AND DATE_FORMAT('2014-07-04','%Y-%m-%d 23:59:59

mysql实现某个时间数据段统计排名 MySQL
select *,(@rowNo:=@rowNo+1) as pm
	from(
		select  id,sum(value) as sumValue
		from 
			youTable as p
		where 
			p.date 
		BETWEEN 
				DATE_FORMAT('2014-06-01','%Y-%m-%d 00:00:00') AND DATE_FORMAT('2014-07-04','%Y-%m-%d 23:59:59')
		group by 
			id
		order by 
			sumValue
		desc
)as rs
,(select @rowNo:=0) pm
Copy after login
Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template