view raw
aofe1337 aofe1337 - 11 months ago 43
SQL Question

SQL Min and Count

What I'm trying to achieve is to display the count number of books in categories

Where Count(Category) > Minimum number in Count(Category)


If categories are

A = 1
b = 2
c = 3
D = 1
E = 1

I'm trying to show the categories which are > 1 using MIN.

The error I'm getting is:

ORA-00935: group function is nested too deeply

SELECT Count(Category),
From Books
Having Count((Category) > MIN(Count(Category)
Group BY Category


Looking for something like this:

Select Count(Category),
From Books 
Group BY Category 
Having Count(Category) > (Select Min(cnt)
                          from (Select Count(Category) AS cnt
                                From Books
                                Group By Category))

This will select all categories having a count that is greater than the minimum count among all categories.