[sqlite] SELECT DISTINCT question

2016-05-09 Thread Keith Medcalf
select col1, aggregateFunction(col2) from table group by col3 order by col1 returns the result of the aggregate function applied to all "col2" values in the "col3" group. The col1 value is the last visited row in the group which triggered the aggregate, with a special case for MIN and MAX,

[sqlite] Good way for CEIL, or is there a better way

2016-05-09 Thread Darren Duncan
On 2016-05-09 7:54 PM, Rowan Worth wrote: > On 10 May 2016 at 08:31, Darren Duncan wrote: > >> The Ceiling function is not that simple, unless you know that your rank >> and outOf are always non-negative numbers. If they might be negative, you >> would -1 rather than +1 when the result is

[sqlite] determining is-leap-year in sqlite

2016-05-09 Thread Stephan Beal
On Mon, May 9, 2016 at 7:00 PM, jungle Boogie wrote: > On 8 May 2016 at 23:13, Stephan Beal wrote: > > On Mon, May 9, 2016 at 5:40 AM, Stephan Beal > wrote: > > > >> That suggests that the script is not consistently telling sqlite which > TZ > >> to use in all calculations. i will take a look

[sqlite] SELECT DISTINCT question

2016-05-09 Thread Scott Robison
At this point, backward compatibility. Enough people use it expecting it to work that it would be bad to change the behavior. On Mon, May 9, 2016 at 6:42 PM, dandl wrote: > > bounces at mailinglists.sqlite.org] On Behalf Of Keith Medcalf > > > Why are you using BOTH distinct and group by on the

[sqlite] SELECT DISTINCT question

2016-05-09 Thread Scott Robison
Hick Gunter gave the documented explanation above. On Mon, May 9, 2016 at 6:18 PM, dandl wrote: > The interesting thing about this query is that you can drop any of > DISTINCT, > GROUP BY or ORDER BY and get the same result. > > But my question was not "how can I rewrite my query?". It was: how

[sqlite] Good way for CEIL, or is there a better way

2016-05-09 Thread Darren Duncan
On 2016-05-09 4:24 AM, Cecil Westerhof wrote: > I need to have a CEIL function in SQLite. This is the way I implemented it: > WITH percentage AS ( > SELECT date > , 100.0 * rank / outOf AS percentage > , CAST(100.0 * rank / outOf AS int) AS castedPercentage >

[sqlite] Which CHECK constraint failed

2016-05-09 Thread Cecil Westerhof
2016-05-09 16:18 GMT+02:00 Dominique Devienne : > On Mon, May 9, 2016 at 3:48 PM, Dominique Devienne > wrote: > > On Mon, May 9, 2016 at 3:46 PM, Dominique Devienne > wrote: > >> On Mon, May 9, 2016 at 3:21 PM, Cecil Westerhof > wrote: > >>> [...] Is there a way to get this information? > >> >

[sqlite] Which CHECK constraint failed

2016-05-09 Thread Dominique Devienne
On Mon, May 9, 2016 at 3:48 PM, Dominique Devienne wrote: > On Mon, May 9, 2016 at 3:46 PM, Dominique Devienne > wrote: >> On Mon, May 9, 2016 at 3:21 PM, Cecil Westerhof >> wrote: >>> [...] Is there a way to get this information? >> >> Just name your CHECK constraint, and use a recent

[sqlite] Good way for CEIL, or is there a better way

2016-05-09 Thread OBones
E.Pasma wrote: > 09-05-2016, OBones: >> Isn't Ceil(Value) simply Round(Value + 0.5) ? > But Round(0.5) = 1 > May be Round(Value+0.4) is good enough? Well, yes, there's an issue at 0, but for anything else positive, it should be good enough.

[sqlite] Good way for CEIL, or is there a better way

2016-05-09 Thread E.Pasma
09-05-2016, OBones: > Isn't Ceil(Value) simply Round(Value + 0.5) ? But Round(0.5) = 1 May be Round(Value+0.4) is good enough?

[sqlite] Which CHECK constraint failed

2016-05-09 Thread Dominique Devienne
On Mon, May 9, 2016 at 3:46 PM, Dominique Devienne wrote: > On Mon, May 9, 2016 at 3:21 PM, Cecil Westerhof > wrote: >> I made a table with a few CHECK constraints. When an INSERT is not >> possible, I would like to know which CHECK constraint fired. Is there a way >> to get this information?

[sqlite] Which CHECK constraint failed

2016-05-09 Thread Dominique Devienne
On Mon, May 9, 2016 at 3:21 PM, Cecil Westerhof wrote: > I made a table with a few CHECK constraints. When an INSERT is not > possible, I would like to know which CHECK constraint fired. Is there a way > to get this information? Just names your CHECK constraint, and use a recent version of

[sqlite] Which CHECK constraint failed

2016-05-09 Thread Cecil Westerhof
I made a table with a few CHECK constraints. When an INSERT is not possible, I would like to know which CHECK constraint fired. Is there a way to get this information? -- Cecil Westerhof

[sqlite] SQLite custom function for regular expression using c/c++

2016-05-09 Thread Chris Brody
On Mon, May 9, 2016 at 2:20 PM, Richard Hipp wrote: > On 5/9/16, Chris Brody wrote: >> On Wed, May 4, 2016 at 2:52 PM, Richard Hipp wrote: >>> On 5/4/16, Bhagwat Balshetwar wrote: I want to write the custom function for regular expression using C/C++. >>> >>> You mean like this one: >>>

[sqlite] Good way for CEIL, or is there a better way

2016-05-09 Thread Cecil Westerhof
2016-05-09 13:57 GMT+02:00 Michele Pradella : > > 2016-05-09 13:40 GMT+02:00 Michele Pradella : >> >> I need to have a CEIL function in SQLite. This is the way I implemented >>> it: >>> WITH percentage AS ( SELECT date , 100.0 * rank / outOf AS

[sqlite] Good way for CEIL, or is there a better way

2016-05-09 Thread Stephan Beal
On Mon, May 9, 2016 at 1:52 PM, Cecil Westerhof wrote: > ?But I want it to be possible for ?everyone? to use the application. People > need to implement my function then. Or am I wrong about that? > fyi, ceil(3) is c99, not c89, which is likely the (or a) reason it's not included in sqlite by

[sqlite] SQLite custom function for regular expression using c/c++

2016-05-09 Thread Chris Brody
On Wed, May 4, 2016 at 2:52 PM, Richard Hipp wrote: > On 5/4/16, Bhagwat Balshetwar wrote: >> I want to write the custom function for regular expression using C/C++. > > You mean like this one: https://www.sqlite.org/src/artifact/a68d25c659bd2d89 Is there any reason this cannot be included as

[sqlite] Good way for CEIL, or is there a better way

2016-05-09 Thread Michele Pradella
> 2016-05-09 13:40 GMT+02:00 Michele Pradella : > >> I need to have a CEIL function in SQLite. This is the way I implemented it: >>> WITH percentage AS ( >>> SELECT date >>> , 100.0 * rank / outOf AS percentage >>> , CAST(100.0 * rank / outOf AS int) AS

[sqlite] Good way for CEIL, or is there a better way

2016-05-09 Thread Cecil Westerhof
2016-05-09 13:40 GMT+02:00 Michele Pradella : > I need to have a CEIL function in SQLite. This is the way I implemented it: >> WITH percentage AS ( >> SELECT date >> , 100.0 * rank / outOf AS percentage >> , CAST(100.0 * rank / outOf AS int) AS

[sqlite] Good way for CEIL, or is there a better way

2016-05-09 Thread Cecil Westerhof
2016-05-09 13:36 GMT+02:00 OBones : > Cecil Westerhof wrote: > >> I need to have a CEIL function in SQLite. This is the way I implemented >> it: >> WITH percentage AS ( >> SELECT date >> , 100.0 * rank / outOf AS percentage >> , CAST(100.0 * rank / outOf AS

[sqlite] Good way for CEIL, or is there a better way

2016-05-09 Thread Michele Pradella
> I need to have a CEIL function in SQLite. This is the way I implemented it: > WITH percentage AS ( > SELECT date > , 100.0 * rank / outOf AS percentage > , CAST(100.0 * rank / outOf AS int) AS castedPercentage > FROM ranking > ) > SELECT date > ,

[sqlite] Good way for CEIL, or is there a better way

2016-05-09 Thread OBones
Cecil Westerhof wrote: > I need to have a CEIL function in SQLite. This is the way I implemented it: > WITH percentage AS ( > SELECT date > , 100.0 * rank / outOf AS percentage > , CAST(100.0 * rank / outOf AS int) AS castedPercentage > FROM ranking > ) >

[sqlite] Good way for CEIL, or is there a better way

2016-05-09 Thread Cecil Westerhof
I need to have a CEIL function in SQLite. This is the way I implemented it: WITH percentage AS ( SELECT date , 100.0 * rank / outOf AS percentage , CAST(100.0 * rank / outOf AS int) AS castedPercentage FROM ranking ) SELECT date , (CASE WHEN percentage =

[sqlite] Incremental backup/sync facility?

2016-05-09 Thread Wade, William
> From: Stephan Buchert [mailto:stephanb007 at gmail.com] > Sent: Saturday, May 07, 2016 12:10 AM > Copying the WAL files is probably more efficient than the SQL text solutions > (considering that roughly 5 GB of binary data are weekly added), and it seems > easy to implement, so I'll probably

[sqlite] SELECT DISTINCT question

2016-05-09 Thread dandl
Just to add to the below: S#| SNAME | STATUS | CITY --- S1| Smith | 20 | London S2| Jones | 10 | Paris S3| Blake | 30 | Paris S4| Clark | 20 | London S5| Adams | 30 | Athens SELECT DISTINCT "CITY" FROM "S" GROUP BY "CITY"

[sqlite] SELECT DISTINCT question

2016-05-09 Thread dandl
I have the following query: SELECT DISTINCT "EVALA112"("S#") AS "^" FROM "S" ORDER BY "S#" ASC ; [This is generated code, not hand-written. The table S is from CJ Date sample data.] This query appears to work correctly. The function is an aggregation, and requires the data to be sorted. This

[sqlite] database is locked when using SQLite3 and MPI to generate different databases

2016-05-09 Thread Rowan Worth
On 8 May 2016 at 10:14, just_rookie <925345468 at qq.com> wrote: > Obviously, I did not do incompatible things with a database at the same > time. > You are attempting to drop a table in databases 300_500.db and 600_900.db. Obviously another process must create that table, since your test code

[sqlite] 64bit DLL vs 32bit

2016-05-09 Thread jic...@barrioinvi.net
On 2016-05-07 01:29, Simon Slavin wrote: > On 7 May 2016, at 3:28am, Keith Medcalf wrote: > >> I presume you mean that running 32-bit application on a 64-bit OS is >> slower than the same application run on a 32-bit OS. > > Hold on. The original poster was talking about using a 32-bit DLL,

[sqlite] Fastest way to backup/copy database?

2016-05-09 Thread Adam Devita
Re WAL mode trick. I think you would want to complete a checkpoint and then do the backup, ensuring that no check-points are done during your backup time. This way, you know that your committed transactions prior to the backup are in the file being backed up. regards, Adam On Sat, May 7, 2016

[sqlite] determining is-leap-year in sqlite

2016-05-09 Thread jungle Boogie
On 8 May 2016 at 23:13, Stephan Beal wrote: > On Mon, May 9, 2016 at 5:40 AM, Stephan Beal wrote: > >> That suggests that the script is not consistently telling sqlite which TZ >> to use in all calculations. i will take a look at it as time >> > > just fyi: i can now reproduce the problem on my

[sqlite] SQLite custom function for regular expression using c/c++

2016-05-09 Thread Richard Hipp
On 5/9/16, Chris Brody wrote: > On Wed, May 4, 2016 at 2:52 PM, Richard Hipp wrote: >> On 5/4/16, Bhagwat Balshetwar wrote: >>> I want to write the custom function for regular expression using C/C++. >> >> You mean like this one: >> https://www.sqlite.org/src/artifact/a68d25c659bd2d89 > > Is

[sqlite] determining is-leap-year in sqlite

2016-05-09 Thread Stephan Beal
On Mon, May 9, 2016 at 5:40 AM, Stephan Beal wrote: > That suggests that the script is not consistently telling sqlite which TZ > to use in all calculations. i will take a look at it as time > just fyi: i can now reproduce the problem on my x64, where my days are shifted 1 to the left. Not sure

[sqlite] SELECT DISTINCT question

2016-05-09 Thread Keith Medcalf
Why are you using BOTH distinct and group by on the same column? You only need one or the other. If you are redundantly redundant I would hope that the optimizer makes redundant (as in gets rid of, for those that are not English) the redundancies ... > -Original Message- > From:

[sqlite] SELECT DISTINCT question

2016-05-09 Thread Hick Gunter
This is documented behaviour for SQLite: SELECT a, MAX(b) table; Will return (one of) the a value(s) that comes from the same row as the MAX(b). If there are not exactly on of MIN or MAX aggregate functions, SQLite is free to pick any row (within a group) to return non-aggregated columns from.

[sqlite] determining is-leap-year in sqlite

2016-05-09 Thread Stephan Beal
That suggests that the script is not consistently telling sqlite which TZ to use in all calculations. i will take a look at it as time allows. Probably just need to be sure to consistently pass the final argument to strftime(). - stephan (Sent from a mobile device, possibly from bed. Please

[sqlite] SELECT DISTINCT question

2016-05-09 Thread Scott Robison
On Sun, May 8, 2016 at 7:45 PM, dandl wrote: > Just to add to the below: > > S#| SNAME | STATUS | CITY > --- > S1| Smith | 20 | London > S2| Jones | 10 | Paris > S3| Blake | 30 | Paris > S4| Clark | 20 | London > S5| Adams |