Okay
  Public Ticket #1981811
Row Numbers
Closed

Comments

  • Jim started the conversation

    How can I add a row number to the table.  I want the rank shown for my salespeople  In MYSQL, I'd do something like this.  but SET is not support on your tool

    SET @row_number:=0;
    select  (@row_number:=@row_number + 1) ,display_name, Sales from (
    select  display_name, count(amount) as Sales from wp_affiliate_wp_referrals r 
    inner join wp_affiliate_wp_affiliates a on a.affiliate_id = r.affiliate_id
    inner join wp_users u on u.ID = a.user_id

    where r.status = 'unpaid' and r.affiliate_id not in (7,8,9)
    group by r.affiliate_id order by count(amount) desc ) as sq;


  •  2,572
    Aleksandar replied

    Hello Jim

    Can you, please, tell me how the table was created?

    If you're creating a table linked to an existing SQL table, you can add the auto-increment column in PHPMyAdmin, and it should be displayed when you use the query like:

    SELECT * FROM mytable

    If you have a manual table, then you already have a unique auto-increment ID column, called wdt_ID it is just hidden. You can see it by opening the yellow button (Complete column list):

    6733976081.png

    Best regards.

    Kind Regards, 

    Aleksandar Vuković
    [email protected]

    Rate my support

    wpDataTables: FAQ | Facebook | Twitter | InstagramFront-end and back-end demo | Docs

    Amelia: FAQ | Facebook | Twitter | InstagramAmelia demo sites | Docs | Discord Community

    You can try wpDataTables add-ons before purchasing on these sandbox sites:

    Powerful Filters | Gravity Forms Integration for wpDataTables | Formidable Forms Integration for wpDataTables | Master-Detail Tables

  • Jim replied

    This is not a table, it is a query, I have a query that ranks my salespeople by sales and I want to be able to show a number on my output

    1. Jim

    2 Bob

    3. Bill

    etc.  I was able to do it with a SET statement, below, but this was not supported in your tool.  So Irigured there is probably a way to do a calculated column that would put the number using yoru tool, but I could not find a way to add row numbers to the output.  But this is not a table, it's the reesults of a query


    On another note.  When I do a query and I have it sorted, when I pass it to the chart, it is no longer sorted and i can't show the chart series in the correct order.  How do I sort a chart series.

  •  2,572
    Aleksandar replied

    Hello Jim.

    I understand it is a query, but to display it using wpDataTables, that query has to be shown in a table. So if this query works in PHPMyAdmin - it should work in wpDataTables as well.

    Is there a way you could export your database, zip it, and send it to us (you can attach it here, just make sure to enable the "Private" response so it is only visible to us), and I can try the same query you used, and probably provide a solution?

    Best regards.

    Kind Regards, 

    Aleksandar Vuković
    [email protected]

    Rate my support

    wpDataTables: FAQ | Facebook | Twitter | InstagramFront-end and back-end demo | Docs

    Amelia: FAQ | Facebook | Twitter | InstagramAmelia demo sites | Docs | Discord Community

    You can try wpDataTables add-ons before purchasing on these sandbox sites:

    Powerful Filters | Gravity Forms Integration for wpDataTables | Formidable Forms Integration for wpDataTables | Master-Detail Tables