I have a table software (id_software, software_name, category)
What SQL query to show only 2 software for each category ?
For example I want to get :
|id_software | software_name | category|
-+------------+---------------+---------+-
| 1 | Photoshop | 5 |
| 2 | illustrator | 5 |
| 3 | Firefox | 1 |
| 4 | I.E | 1 |
-+--------------------------------------+-
2
Answers
Source: http://mindbuffer.wordpress.com/2013/07/09/mysql-get-the-top-2-rows-for-each-category-with-certain-condition/
You could use the row_number function for this.
This gives you the first two software entries based on softwareId for every category.