MySQL Forums
Forum List  »  InnoDB

Re: Rank with Total
Posted by: Ra Nala
Date: November 04, 2017 11:44AM

Hi Peter,

Thanks for your help.

Using below logic i am able to get rownumber , could you please help on rank_total(i.e. value as 3 should come) ?

in table i should not update, i should get rank_total using below query. Please\kindly help.

id | Name | rownumber rank_total
1 a 1 3
1 b 2 3
1 ads 3 3

SELECT
t.*,
@cur:= IF(id=@id, @cur+1, 1) AS RowNumber,
@id := id
FROM
t CROSS JOIN
(SELECT @id:=(SELECT MIN(id) FROM t), @cur:=0) AS init
ORDER BY
t.id

Options: ReplyQuote


Subject
Views
Written By
Posted
82
November 02, 2017 12:38PM
38
November 02, 2017 01:12PM
Re: Rank with Total
26
November 04, 2017 11:44AM
35
November 04, 2017 12:07PM
30
November 04, 2017 12:15PM
23
November 04, 2017 05:36PM
25
November 05, 2017 11:49AM
27
November 05, 2017 03:43PM
20
November 06, 2017 12:01PM
19
November 06, 2017 12:51PM


Sorry, only registered users may post in this forum.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.