Sort

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • jacki

    Sort

    I have a problem with sort. I have to calculate in a table how many times an
    individual user appears; I also have to show 3 users who appear the most.

    Can somebody please help with an example of how to do this?

    Thanks


  • Kevin

    #2
    Re: Sort

    I'm assuming this is a MySQL question. Here's a query that illustrates how
    to count repititions in table:

    SELECT COUNT( userid ) AS repetitions, userid FROM `table`
    GROUP BY userid
    ORDER BY repetitions DESC

    This would return a list of distinct userids and the number of times each
    userid appeared in the table, in descending order.

    "jacki" <jacki@jacki.co m> wrote in message
    news:ctll6l$9d0 $1@bagan.srce.h r...[color=blue]
    >I have a problem with sort. I have to calculate in a table how many times
    >an
    > individual user appears; I also have to show 3 users who appear the most.
    >
    > Can somebody please help with an example of how to do this?
    >
    > Thanks
    >
    >[/color]


    Comment

    • Chung Leong

      #3
      Re: Sort

      "jacki" <jacki@jacki.co m> wrote in message
      news:ctll6l$9d0 $1@bagan.srce.h r...[color=blue]
      > I have a problem with sort. I have to calculate in a table how many times[/color]
      an[color=blue]
      > individual user appears; I also have to show 3 users who appear the most.
      >
      > Can somebody please help with an example of how to do this?
      >
      > Thanks
      >
      >[/color]

      The function you need is array_count_val ues(). Sort the result with asort()
      for the second part of your problem.


      Comment

      Working...