Number sequence

0

I have a database (MySQL) with 100 registered customers and I'm creating a table of purchases of these clients, I know that the database creates an > I would like to put on this table only the first 20 customers who buy more products and would soon have the ranking number and the name but I can not.

    
asked by anonymous 16.11.2014 / 19:35

1 answer

2

Probably solving the database is the best path you've asked.

In the part that you do the query:

SELECT cliente FROM clientes ORDER BY totalcompras DESC LIMIT 20

If the purchases are in another base (which is probably the case), you can use grouping / JOIN functions or even subquery.

To number the lines in the output, you can use part of this solution:

  

Rank Database [# 1 of 10]

    
16.11.2014 / 19:40