Results 1 to 3 of 3
  1. #1
    Join Date
    Sep 2008
    Posts
    34

    Unanswered: another confusing sql script - help me please!

    I have a table with fields KEY and TYPE.
    I want to display results for KEY and the AVERAGE of TYPE, ordered by TYPE and grouped by KEY, but only when KEY occurs 10 or more times in the table. If KEY does not occur 10 or more times, I don't want to see it.

    Any help would be appreciated.
    Last edited by curtmorehouse; 10-02-08 at 20:55.

  2. #2
    Join Date
    Jun 2003
    Location
    Toronto, Canada
    Posts
    5,516
    Provided Answers: 1
    That definitely should include COUNT() and HAVING...
    ---
    "It does not work" is not a valid problem statement.

  3. #3
    Join Date
    Sep 2008
    Posts
    34

    thanks

    I got it to work after i looked up the HAVING feature.

    Code:
    select AVG($type), $key from database.table
    group by $key HAVING COUNT($key) > 10
    order by AVG($type) $order, $key

Posting Permissions

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