US and Worldwide: +1 (866) 660-7555
Results 1 to 6 of 6

Thread: Group by?

  1. #1
    Join Date
    Jul 2012
    Posts
    23

    Default Group by?

    Hello


    I have a database in which one of the attributes (column) has records (rows) with names A, B and C.
    I need to count the frequency of these names in the database.
    Does anyone have any idea how I do it?


    thanks

  2. #2
    Join Date
    Jun 2012
    Posts
    1,443

    Default

    You could count the values via SQL:

    Code:
    SELECT theColumn, COUNT(1) AS occurences
    FROM theTable
    WHERE theColumn IN ('A', 'B', 'C')
    GROUP BY theColumn
    ORDER BY theColumn
    pdi-ce-4.3.0-stable
    OpenJDK IcedTea 2.3.7 (7u21)
    ubuntu 12.04 LTS (x86_64)

  3. #3
    Join Date
    Jul 2012
    Posts
    23

    Default

    Is there only via SQL?

  4. #4
    Join Date
    Jun 2012
    Posts
    1,443

    Default

    No, of course, but it usually is the most efficient way to group data, that come from a database.

    You can achieve the same result with a combination of a Sort, Filter and GroupBy step.
    pdi-ce-4.3.0-stable
    OpenJDK IcedTea 2.3.7 (7u21)
    ubuntu 12.04 LTS (x86_64)

  5. #5
    Join Date
    Jul 2012
    Posts
    23

    Default

    I understand.

    thanks

  6. #6
    Join Date
    Jul 2012
    Posts
    8

    Default

    If you don't do the grouping by SQL on the database, you would have to get all the records first from your table before you do the actual grouping.
    If your table is small it might not make a big difference, but on large tables this would decrease the performance of your transformation. (because for example getting a million rows first could take some time..)

    Regards

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •