I don't know about anybody else but I can't tell what you want to do.
 
Have you got some sample data and the results you expect from it?
 
 
Michael D. Black
Senior Scientist
Northrop Grumman Mission Systems
 

________________________________

From: sqlite-users-boun...@sqlite.org on behalf of Peng Yu
Sent: Fri 7/2/2010 11:29 AM
To: General Discussion of SQLite Database
Subject: EXTERNAL:Re: [sqlite] How to select an entry that appears <=n times 
and only show n times if it appears more than n times?



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


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

Reply via email to