1 Reply Latest reply on Apr 6, 2013 3:25 AM by HamidHelal

    SQL help, how to group by column A and then get top frequency of column B?

    1001411
      Assuming the following table, operation represents each kind of transaction operation
      table operation employee other column c
      '<' id1
      '<' id1
      '<' id2
      '*' id3
      '/' id1

      question, for each operation, which employee do the most? which employee do the 2nd most?
      I thought I need to group by operation first, and then get the frequency of employee, and get the top 1 or top 2 frequency highest.
      But I am stuct, and do not know how to write the sql.
        • 1. Re: SQL help, how to group by column A and then get top frequency of column B?
          HamidHelal
          998408 wrote:
          Assuming the following table, operation represents each kind of transaction operation
          table operation employee other column c
          '<' id1
          '<' id1
          '<' id2
          '*' id3
          '/' id1

          question, for each operation, which employee do the most? which employee do the 2nd most?
          I thought I need to group by operation first, and then get the frequency of employee, and get the top 1 or top 2 frequency highest.
          But I am stuct, and do not know how to write the sql.
          Welcome to OTN. Ops! posted in wrong forum. Just post in {forum:id=75}. Before posting there close this thread marking as answered.


          If someone's response is helpful or correct, please mark it accordingly.*