mysql sql語句查詢指定資料在查詢資料列表中排名第幾
需求是這樣的,我們有個排名列表,需要查詢出當前條件下的指定人員的資訊是在排序後的第幾條。
兩種sql解決方案
SELECT a.* FROM
(SELECT *, (@i :[email protected] + 1) AS No FROM jira_issue_statistics , (SELECT @i:=0) AS it WHERE year = 2018 and mounth = 10 ORDER BY count DESC) as a WHERE a.reporter = 'jianglei_tmp'
方案2:
SELECT year,reporter,count,rowno FROM (
select * from
(
select * from(
SELECT year, mounth, reporter, count,(@rowno:
) tempst where tempst.year = 2018 and tempst.mounth = 10 ORDER BY count desc
) c WHERE c.reporter='jianglei_tmp';