<html><head><style type="text/css"><!-- DIV {margin:0px;} --></style></head><body><div style="font-family:arial, helvetica, sans-serif;font-size:12pt"><DIV></DIV>
<DIV>Thanks, but that doesn't do what I want. What I need is the row number that results from this query (simplified for example).</DIV>
<DIV>&nbsp;</DIV>
<DIV>SELECT c.mail, COUNT(c.cid) AS comment_count FROM comments c&nbsp;WHERE c.mail &lt;&gt; '' GROUP BY c.mail ORDER BY comment_count DESC</DIV>
<DIV>&nbsp;</DIV>
<DIV>And remember that pager_query is going to add LIMIT xxx, 10.<BR>&nbsp;</DIV>
<P><FONT face="bookman old style, new york, times, serif" color=#ff007f size=4><EM><STRONG>Nancy</STRONG></EM></FONT></P>
<P>&nbsp;</P>
<P><FONT face="arial, helvetica, sans-serif">Injustice anywhere is a threat to justice everywhere. -- Dr. Martin L. King, Jr.</FONT></P>
<DIV><BR></DIV>
<DIV style="FONT-SIZE: 12pt; FONT-FAMILY: arial, helvetica, sans-serif"><BR>
<DIV style="FONT-SIZE: 12pt; FONT-FAMILY: times new roman, new york, times, serif"><FONT face=Tahoma size=2>
<HR SIZE=1>
<B><SPAN style="FONT-WEIGHT: bold">From:</SPAN></B> Nikola Kotur &lt;kotnick@gmail.com&gt;<BR><B><SPAN style="FONT-WEIGHT: bold">To:</SPAN></B> development@drupal.org<BR><B><SPAN style="FONT-WEIGHT: bold">Sent:</SPAN></B> Fri, October 29, 2010 5:19:17 AM<BR><B><SPAN style="FONT-WEIGHT: bold">Subject:</SPAN></B> Re: [development] Ranking in a query<BR></FONT><BR>On Thu, 2010-10-28 at 06:32 -0700, nan wich wrote:<BR>
<BLOCKQUOTE TYPE="CITE">I have a query that counts comments and all is well with it. But I'd like add a ranking column to the display. The problem is that it uses tablesort, so the ranking has to be in the query because I don't know which column will be used to sort the display. Oh, it is also paged so I can't count on the first row being #1 and so on.&nbsp;&nbsp; Has anyone got an idea on how to add a ranking column to the query? (MySql only.) <BR></BLOCKQUOTE><BR>Nancy, here's a query that returns a nid, and it's row position:<BR><BR>SELECT @row := @row + 1 as row, n.nid FROM node n, (SELECT @row := 0) r;<BR><BR>You can start from there.<BR><BR></DIV></DIV></div></body></html>