Re: [sqlite] finding the number of records until a value is different

2017-12-29 Thread Max Vlasov
I think it's possible with CTE. Recently I wondered whether it would be possible to implement an operation that might be called "an accumulated group by". It's when you enumerate the rows and based on the values of the previous row and current row you apply some new "group" value that can be used

Re: [sqlite] finding the number of records until a value is different

2017-12-07 Thread Kees Nuyt
On Thu, 07 Dec 2017 19:46:21 +0100, nitpi...@arcor.de wrote: > Hi all, > > I have a DB i.e. like this: > > table values > bctemp > 35123 > 35124 > 35123 > 20123 > 12123 > 12123 > 16123 > 35123 > 35123 > 35123 > 35123 > 35123 > > The value in

Re: [sqlite] finding the number of records until a value is different

2017-12-07 Thread Keith Medcalf
Have your application read the table in reverse order. Then when the value of BC changes, stop incrementing a counter and close the select. You can use whatever ordering you like just so long as it is "descending" (that is reading backwards). ((Code example in Python -- you can use wordier

Re: [sqlite] finding the number of records until a value is different

2017-12-07 Thread Marc L. Allen
Ok I'm on this list because I love reading all the comments and discussion about sqlite and DBs in general. I haven't used sqlite in quite awhile, so I don't know how well this will work, but... Assuming you have a row number as well, such as CREATE TABLE x ( row_number int,

Re: [sqlite] finding the number of records until a value is different

2017-12-07 Thread David Raymond
The question you're gonna get asked of course is "what are you sorting by?" If it's for example rowid, then this convoluted thing will work, though probably inefficiently. create table tbl (bc int, temp int); insert into tbl values (35, 123), (35, 124), (35, 123), (20, 123), (12, 123), (12,