Re: [sqlite] help with query

2015-01-14 Thread snowbiwan
Maybe something like this would work for you: SELECT * FROM table WHERE data1 IN (SELECT data1 FROM table GROUP BY data1 HAVING count(*)>=3); ~snowbiwan -- View this message in context: http://sqlite.1065341.n5.nabble.com/help-with-query-t

Re: [sqlite] help with query

2015-01-13 Thread Keith Medcalf
A correlated subquery: select * from t where (select count(*) from t as b where b.data1 = t.data1) >= 3; or with a subselected set of valid rows: select * from t where data1 in (select data1 from t as b group by data1 h

Re: [sqlite] help with query

2015-01-13 Thread Hajo Locke
Hello, thanks a lot. Works like a charm! I should really do more sql. Thanks, Hajo Am 13.01.2015 um 09:03 schrieb Hick Gunter: Step 1: count the occurrences: SELECT data1,count() AS count FROM table GROUP BY data1; Step 2: get the rows with a count above the limit SELECT data1,count() AS

Re: [sqlite] help with query

2015-01-13 Thread Hick Gunter
Step 1: count the occurrences: SELECT data1,count() AS count FROM table GROUP BY data1; Step 2: get the rows with a count above the limit SELECT data1,count() AS count FROM table GROUP BY data1 HAVING count >= 3; Step 3: get the keys from the rows SELECT data1 FROM (SELECT data1,count() AS cou

Re: [sqlite] Help with query

2010-11-15 Thread Jeff Archer
>From: Drake Wilson Sun, November 14, 2010 7:50:19 AM >> SELECT COUNT(Offset_Y) FROM (SELECT DISTINCT Offset_Y FROM Tiles WHERE >>PatternID >> >> = 1); >> >> Is it possible to have a single query that will generate a row for each >> PattenID, COUNT(Offset_Y) combination? > >Does SELECT Pattern

Re: [sqlite] Help with query

2010-11-14 Thread Drake Wilson
Quoth Jeff Archer , on 2010-11-13 11:20:51 -0800: > And I can get the number of unique Y offsets in a pattern like so: > > SELECT COUNT(Offset_Y) FROM (SELECT DISTINCT Offset_Y FROM Tiles WHERE > PatternID > = 1); > > Is it possible to have a single query that will generate a row for each > P

Re: [sqlite] Help with query

2008-04-08 Thread P Kishor
On 4/8/08, Neville Franks <[EMAIL PROTECTED]> wrote: > Thanks Igor and Puneet, > These are very different solutions, or so it appears to me. > > Any idea whether the join or the sub-select would be faster? In my > example there is an index on tagid. Just as in any language, SQL also gives many

Re: [sqlite] Help with query

2008-04-08 Thread Neville Franks
Thanks Igor and Puneet, These are very different solutions, or so it appears to me. Any idea whether the join or the sub-select would be faster? In my example there is an index on tagid. Wednesday, April 9, 2008, 8:12:53 AM, you wrote: IT> Neville Franks <[EMAIL PROTECTED]> wrote: >> I have a

Re: [sqlite] Help with query

2008-04-08 Thread Igor Tandetnik
Neville Franks <[EMAIL PROTECTED]> wrote: > I have a table that holds 1 to many items. To keep it simple say it > has 2 columns: tagid and noteid. A given tagid can have many noteid's. > ex. > tagid noteid > -- -- > a 1 > a 4 > a 7 > b 7 > b 3 > c 1 >

Re: [sqlite] Help with query

2008-04-08 Thread P Kishor
On 4/8/08, Neville Franks <[EMAIL PROTECTED]> wrote: > I have a table that holds 1 to many items. To keep it simple say it > has 2 columns: tagid and noteid. A given tagid can have many noteid's. > ex. > tagid noteid > -- -- > a 1 > a 4 > a 7 > b 7 > b

Re: [sqlite] Help with query

2004-10-09 Thread Brian Pugh
Fred, A query I can understand! This was my attempt, and worked to some degree, but yours is more workable and, I feel, more accurate "select NewsData.Postcode,NewsData.Address1,Agents.Code,Agents.Shopname,Agents.Addre ss1.Agents.Price from NewsData join Agents on NewsData.Postcode where NewsDat

Re: [sqlite] Help with query

2004-10-08 Thread Fred Bleuzet
Without testing on my side... how's that? select a.Shop1, a.Shop2, a.Postcode, b.Code, b.Shopname, b.Address1, b.Price from NewsData a, Agents b where (a.Shop1 > '' or a.Shop2 > '') and b.Shopname > '' and (a.Shop1 = b.Shopname or a.Shop2 = b.Shopname) order by a.Postcode asc On Fri, 8 Oct 2004