On 2/4/2011 11:14 AM, Scott Baker wrote: > On 02/04/2011 04:00 AM, sqlite-users-requ...@sqlite.org wrote: >> On 2/3/2011 12:10 PM, Scott Baker wrote: >>>> #3) Query for customers who bought exactly 2 apples? >> select CustomerID from Customers >> group by CustomerID >> having sum(Type = 'Apple') = 2; > > I thought of one other case that I couldn't figure out. How would I get > a count (instead of a list) of all the customers that bought exactly two > apples?
select count(*) from ( select CustomerID from Customers group by CustomerID having sum(Type = 'Apple') = 2; ) -- Igor Tandetnik _______________________________________________ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users