I am trying to create a function that returns an array of idnumbers (for pages) based on the number of views of the page ranked by number of views. Every time someone views table, there is a new row. So I basically need to count the rows but do so by pageid. I’m thinking it uses count but SQL is not my strong suit. Can anyone suggest the proper way to do this?
table 'views':
id | pageid |
SELECT COUNT(id) from views WHERE pageid== '22' ORDER BY COUNT(id)
Try this