Numbering of rows in accordance with the order of values of a primary key page 2
Let's add a some difficulty to the task and try to number the models of each maker separately. We'll take the above solution and introduce the following changes:
1. Appending the equality of makers to the join condition with aids to unite the models of each maker into separate group.
That's all in principle, but the result is not an illustrative one.
2. Adding a maker into SELECT list, in so doing this is not the matter which table it will be taken from in view of makers equality. But the column must be presented in the GROUP BY clause also (MySQL is not a case):
3. At last, for illustrative purposes we'll use sorting. The maker column should be the first sorting column to deduce each group separately.
I hope you will not encounter any difficulty while numbering models over product types. Do it by yourself as an exercise.
Naturally, ranking functions make the query much more simple.