Loading ...
Sorry, an error occurred while loading the content.

Re: Only show things that have count > 1 subquery not working to limit results

Expand Messages
  • kennejd
    Try: select LogValue ,COUNT(*) as frequency from sometable group by LogValue having COUNT(*) 1 order by frequency desc The having clause is an easy way to
    Message 1 of 2 , Mar 31, 2011
    • 0 Attachment
      Try:
      select
      LogValue
      ,COUNT(*) as frequency
      from sometable

      group by
      LogValue

      having
      COUNT(*) > 1
      order by
      frequency desc

      The 'having' clause is an easy way to filter based on an aggregate.

      Jim

      --- In SQLQueriesNoCode@yahoogroups.com, Charles Carroll <911@...> wrote:
      >
      > select COUNT(*) as frequency from sometable AS frequency group by
      > LogValue order by frequency desc
      > works fine
      >
      > select COUNT(*) as frequency from sometable where (select COUNT(*)
      > from LogRaw)>1 group by LogValue order by frequency desc
      > prouduces identical results i.e. it always returns all results and
      > does not skip the the results that only have a count of 1
      >
      > what am I getting wrong in the subquery?
      >
    Your message has been successfully submitted and would be delivered to recipients shortly.