On Fri, Jul 2, 2010 at 11:19 AM, P Kishor <punk.k...@gmail.com> wrote:
> On Fri, Jul 2, 2010 at 11:19 AM, P Kishor <punk.k...@gmail.com> wrote:
>> On Fri, Jul 2, 2010 at 11:15 AM, Peng Yu <pengyu...@gmail.com> wrote:
>>> Hi,
>>>
>>> SELECT DISTINCT type_id FROM foods;
>>>
>>> If I use 'distinct', any entry that shows up greater or equal to one
>>> time will only appear once. But I want to select an entry that appears
>>> <=n times and only show n times if it appears more than n times. I
>>> think that "group by" might help. But I'm not familiar with SQL enough
>>> yet. Would you please let me know what command to use?
>>>
>>
>> Try
>>
>> SELECT <whatever column>, Count(type_id)
>> FROM foods
>> GROUP BY <whatever column>
>> HAVING Count(type_id) < n
>
> make that
>
> HAVING Count(type_id) <= n

But this doesn't show anything that count more than n times. I want
the type_id shows up more than n times in the database only appear n
times in the result of the query.


-- 
Regards,
Peng
_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to