[sqlite] Problem with accumulating decimal values

2015-12-12 Thread Domingo Alvarez Duarte
Hello !then I did a modification to sqlite3 that basically define a new type "sqlite_double" and use it instead of "double" (#define sqlite_double? double) then I can redefine it to _Decimal64 (#define sqlite_double? _Decimal64) this way with a modern C compiler we can have sqlite3 using

[sqlite] Problem with accumulating decimal values

2015-12-12 Thread Frank Millman
From: Frank Millman Sent: Friday, December 11, 2015 4:21 PM To: sqlite-users at mailinglists.sqlite.org Subject: [sqlite] Problem with accumulating decimal values > Hi all > > I am having a problem accumulating decimal values. > > I am actually using Python, but I can reproduce it in the

[sqlite] Problem with accumulating decimal values

2015-12-12 Thread Darren Duncan
Frank, The problem you are having is due to SQLite not following the SQL standard regarding non-integral numeric types. The SQL standard specifies that the DECIMAL type is exact numeric and able to represent decimal numbers exactly. However, when you ask SQLite for a DECIMAL column, that is

[sqlite] Remarks about vtab generate_series.

2015-12-12 Thread E.Pasma
Hello, I have two mini minor remarks about the series.c example as of 2015-08-21 and referred to from the Table-Valued Functions paragraph of https://www.sqlite .org/vtab.html#tabfunc2 1. comment above seriesDisconnect < ** This method is the destructor for series_cursor objects. > ** This

[sqlite] Virtual tables and table-valued functions

2015-12-12 Thread E.Pasma
6 dec 2015, Charles Leifer: > In working on a Python wrapper around virtual tables, I thought it > might be > beneficial if SQLite provided an official C API for creating simple > table-valued functions. The wrapper could build on the existing > virtual > table APIs and would consist of: > >

[sqlite] Selecting total and not used in one query

2015-12-12 Thread Cecil Westerhof
?I have the following query: SELECT (SELECT COUNT(*) FROM proverbs)AS Total , (SELECT COUNT(*) FROM proverbs WHERE NOT used IS NULL) AS Used But I want something like: ?SELECT (SELECT COUNT(*) FROM proverbs)AS Total

[sqlite] Selecting total and not used in one query

2015-12-12 Thread R Smith
On 2015/12/12 4:18 PM, Cecil Westerhof wrote: > ?I have the following query: > SELECT > (SELECT COUNT(*) FROM proverbs)AS Total > , (SELECT COUNT(*) FROM proverbs WHERE NOT used IS NULL) AS Used > > But I want something like: > ?SELECT >

[sqlite] Problem with accumulating decimal values

2015-12-12 Thread Bernardo Sulzbach
On Sat, Dec 12, 2015 at 6:51 AM, Darren Duncan wrote: > > Per another suggestion, the best workaround is to use an INTEGER type > instead, and store an even multiple of whatever your smallest currency unit > size is, eg cents rather than dollars. > As I understood, he is doing the math in

[sqlite] Selecting total and not used in one query

2015-12-12 Thread R Smith
or, more elegantly... WITH PC(t, u, f) AS ( SELECT 1, (P.used IS NOT NULL), (P.used IS NULL) FROM proverbs AS P ) SELECT SUM(PC.t) AS Total, SUM(PC.u) AS Used, SUM(PC.f) AS Free FROM PC; On 2015/12/12 4:18 PM, Cecil Westerhof wrote: > ?I have the following query: > SELECT >

[sqlite] Selecting total and not used in one query

2015-12-12 Thread Cecil Westerhof
2015-12-12 15:24 GMT+01:00 R Smith : > > > On 2015/12/12 4:18 PM, Cecil Westerhof wrote: > >> ?I have the following query: >> SELECT >> (SELECT COUNT(*) FROM proverbs)AS Total >> , (SELECT COUNT(*) FROM proverbs WHERE NOT used IS NULL) AS Used >> >>

[sqlite] Selecting total and not used in one query

2015-12-12 Thread Luuk
On 12-12-15 15:18, Cecil Westerhof wrote: > ?I have the following query: > SELECT > (SELECT COUNT(*) FROM proverbs)AS Total > , (SELECT COUNT(*) FROM proverbs WHERE NOT used IS NULL) AS Used > > But I want something like: > ?SELECT >

[sqlite] Selecting total and not used in one query

2015-12-12 Thread Luuk
On 12-12-15 15:45, Luuk wrote: > > > On 12-12-15 15:18, Cecil Westerhof wrote: >> ?I have the following query: >> SELECT >> (SELECT COUNT(*) FROM proverbs) AS Total >> , (SELECT COUNT(*) FROM proverbs WHERE NOT used IS NULL) AS Used >> >> But I want something like: >> ?

[sqlite] Selecting total and not used in one query

2015-12-12 Thread Igor Tandetnik
On 12/12/2015 9:18 AM, Cecil Westerhof wrote: > But I want something like: > ?SELECT > (SELECT COUNT(*) FROM proverbs)AS Total > , (SELECT COUNT(*) FROM proverbs WHERE NOT used IS NULL) AS Used > , (Total - Used)

[sqlite] Selecting total and not used in one query

2015-12-12 Thread Cecil Westerhof
2015-12-12 16:06 GMT+01:00 Luuk : > On 12-12-15 15:18, Cecil Westerhof wrote: > >> ?I have the following query: >>> SELECT >>> (SELECT COUNT(*) FROM proverbs) AS Total >>> , (SELECT COUNT(*) FROM proverbs WHERE NOT used IS NULL) AS Used >>> >>> But I want something like: >>>

[sqlite] Selecting total and not used in one query

2015-12-12 Thread Cecil Westerhof
2015-12-12 16:23 GMT+01:00 Igor Tandetnik : > On 12/12/2015 9:18 AM, Cecil Westerhof wrote: > >> But I want something like: >> ?SELECT >> (SELECT COUNT(*) FROM proverbs)AS Total >> , (SELECT COUNT(*) FROM proverbs WHERE NOT used IS NULL) AS Used >>

[sqlite] Selecting total and not used in one query

2015-12-12 Thread Simon Slavin
On 12 Dec 2015, at 2:42pm, Cecil Westerhof wrote: >> SELECT >>(SELECT COUNT(*) FROM proverbs) AS Total >>, (SELECT COUNT(*) FROM proverbs WHERE used IS NOT NULL) AS Used >>, (SELECT COUNT(*) FROM proverbs WHERE used IS NULL) AS Free >> > > ?That is what I am using

[sqlite] Selecting total and not used in one query

2015-12-12 Thread Cecil Westerhof
2015-12-12 19:00 GMT+01:00 Simon Slavin : > > On 12 Dec 2015, at 2:42pm, Cecil Westerhof wrote: > > >> SELECT > >>(SELECT COUNT(*) FROM proverbs) AS Total > >>, (SELECT COUNT(*) FROM proverbs WHERE used IS NOT NULL) AS Used > >>, (SELECT COUNT(*) FROM proverbs WHERE used IS

[sqlite] Selecting total and not used in one query

2015-12-12 Thread Simon Slavin
On 12 Dec 2015, at 6:14pm, Cecil Westerhof wrote: > ?Not at the moment. But maybe that is a good idea.? With clauses like >>> WHERE used IS NOT NULL) AS Used >>> WHERE used IS NULL It should transform the work done. Simon.

[sqlite] website documentation wording

2015-12-12 Thread Simon Slavin
On 12 Dec 2015, at 6:19pm, Mohit Sindhwani wrote: > Well, at least as far as SQLite goes, I think this settles it unambiguously > for me: > https://www.youtube.com/watch?v=giAMt8Tj-84 "As soon as I have a person need for Foreign Keys I'm sure you'll see them come in pretty quick." -- Richard

[sqlite] Selecting total and not used in one query

2015-12-12 Thread Cecil Westerhof
2015-12-12 19:17 GMT+01:00 Simon Slavin : > > On 12 Dec 2015, at 6:14pm, Cecil Westerhof wrote: > > > ?Not at the moment. But maybe that is a good idea.? > > With clauses like > > >>> WHERE used IS NOT NULL) AS Used > > >>> WHERE used IS NULL > > It should transform the work done. > ?Here

[sqlite] Selecting total and not used in one query

2015-12-12 Thread Simon Slavin
On 12 Dec 2015, at 7:52pm, Cecil Westerhof wrote: > ?Here http://www.tutorialspoint.com/sqlite/sqlite_indexes.htm it is said > that you should not use an index on columns that use a high number of NULL > values. At the moment that is true. So I should not use an Index?? The tutorial thinks

[sqlite] Selecting total and not used in one query

2015-12-12 Thread Cecil Westerhof
2015-12-12 21:10 GMT+01:00 Simon Slavin : > > On 12 Dec 2015, at 7:52pm, Cecil Westerhof wrote: > > > ?Here http://www.tutorialspoint.com/sqlite/sqlite_indexes.htm it is said > > that you should not use an index on columns that use a high number of > NULL > > values. At the moment that is true.

[sqlite] Putting an index on a boolean

2015-12-12 Thread Cecil Westerhof
I am playing with SQLite. I am thinking about writing an application for projects. At the moment I have the following: CREATE TABLE `projects` ( `projectID` TEXTPRIMARY KEY, `groupID` TEXT, `isPersonal`INTEGER NOT NULL CHECK(isPersonal in (0, 1)), `name`

[sqlite] Putting an index on a boolean

2015-12-12 Thread Richard Hipp
On 12/12/15, Cecil Westerhof wrote: > I am playing with SQLite. I am thinking about writing an application for > projects. At the moment I have the following: > > CREATE TABLE `projects` ( > `projectID` TEXTPRIMARY KEY, > `groupID` TEXT, > `isPersonal`INTEGER NOT

[sqlite] Putting an index on a boolean

2015-12-12 Thread Cecil Westerhof
2015-12-12 21:45 GMT+01:00 Richard Hipp : > On 12/12/15, Cecil Westerhof wrote: > > I am playing with SQLite. I am thinking about writing an application for > > projects. At the moment I have the following: > > > > CREATE TABLE `projects` ( > > `projectID` TEXTPRIMARY KEY, > >

[sqlite] Integrity check with a SQL command

2015-12-12 Thread Cecil Westerhof
I have the following tables: CREATE TABLE "projects" ( "projectID" TEXT PRIMARY KEY, "groupID" TEXT, "isPersonal"INTEGER NOT NULL CHECK(ispersonal in (0, 1)), "name" TEXT, "description" TEXT, "outcome" TEXT ); CREATE INDEX projects_groupID_idx

[sqlite] Putting an index on a boolean

2015-12-12 Thread Darren Duncan
On 2015-12-12 12:56 PM, Cecil Westerhof wrote: >>> By the way: I am thinking about using UUID for projectID and groupID, >> but I >>> heard somewhere that it was a bad idea to use UUID for an indexed field. >> Is >>> this true?? >> >> I think you might have misunderstood. UUID is almost always a

[sqlite] Putting an index on a boolean

2015-12-12 Thread Mark Hamburg
Though to the extent that speed is proportional to data size, it would be good to use something other than hexadecimal to store UUIDs. Binary blobs would be the most compact, but ASCII85 encoding would work well if you need strings. Also, if these values are reused repeatedly as I suspect

[sqlite] Integrity check with a SQL command

2015-12-12 Thread Richard Hipp
On 12/12/15, Cecil Westerhof wrote: > I have the following tables: > CREATE TABLE "projects" ( > "projectID" TEXT PRIMARY KEY, > ); > CREATE INDEX subprojects_projectID_idx > ON projects(projectID); Don't create indexes on primary keys. Doing so still gives a correct answer, but it

[sqlite] Putting an index on a boolean

2015-12-12 Thread Cecil Westerhof
2015-12-12 22:07 GMT+01:00 Darren Duncan : > On 2015-12-12 12:56 PM, Cecil Westerhof wrote: > >> By the way: I am thinking about using UUID for projectID and groupID, >>> but I >>> heard somewhere that it was a bad idea to use UUID for an indexed field. >>> Is >>> this true??

[sqlite] Putting an index on a boolean

2015-12-12 Thread Darren Duncan
For my part, in a database I designed that used a SHA-256 hash for a unique identifier that was then a foreign key from many other tables, I stored that as an integer and not as a hex string. If UUIDs are similarly numbers fundamentally, they possibly could do likewise. I agree with Mark's

[sqlite] Putting an index on a boolean

2015-12-12 Thread Cecil Westerhof
2015-12-12 22:12 GMT+01:00 Mark Hamburg : > Though to the extent that speed is proportional to data size, it would be > good to use something other than hexadecimal to store UUIDs. Binary blobs > would be the most compact, but ASCII85 encoding would work well if you need > strings. > > Also, if

[sqlite] Integrity check with a SQL command

2015-12-12 Thread Cecil Westerhof
2015-12-12 22:13 GMT+01:00 Richard Hipp : > On 12/12/15, Cecil Westerhof wrote: > > I have the following tables: > > CREATE TABLE "projects" ( > > "projectID" TEXT PRIMARY KEY, > > ); > ?? > > CREATE INDEX subprojects_projectID_idx > > ON projects(projectID); > > Don't create indexes on

[sqlite] Putting an index on a boolean

2015-12-12 Thread Keith Medcalf
The first question(s) I would ask are: Are all the fields case sensitive? (according to your definition they are) Are any of them, other than the primary key, unique? (according to your definition they are not) Other than the isPersonal column all of the columns permit a NULL entry. Is this

[sqlite] Putting an index on a boolean

2015-12-12 Thread Keith Medcalf
> > One other point: The use of grave accents to quote column names is a > > mysql-ism. SQLite also supports that for compatibility. But you > > still shouldn't do it. The proper SQL-standard way is double-quote. > ?That is funny: I did not use them at first (or double). But I am using 'DB >

[sqlite] Putting an index on a boolean

2015-12-12 Thread Cecil Westerhof
2015-12-12 22:44 GMT+01:00 Keith Medcalf : > > The first question(s) I would ask are: > Are all the fields case sensitive? (according to your definition they are) > ?Do you mean the name or the contents? ? > Are any of them, other than the primary key, unique? (according to your >

[sqlite] Putting an index on a boolean

2015-12-12 Thread Cecil Westerhof
2015-12-12 22:50 GMT+01:00 Keith Medcalf : > > > One other point: The use of grave accents to quote column names is a > > > mysql-ism. SQLite also supports that for compatibility. But you > > > still shouldn't do it. The proper SQL-standard way is double-quote. > > > ?That is funny: I did not

[sqlite] I have no idea what to install!

2015-12-12 Thread Nicolette Warner
Please forgive my lack of knowledge but for the life of me I can't figure out what to install or how to install what I should be using. I'm using VS2015 Community edition where I'm attempting to create a WPF desktop application for windows (not specific to 8 or 10). I have a rather basic

[sqlite] I have no idea what to install!

2015-12-12 Thread Darren Duncan
On 2015-12-12 4:02 PM, Nicolette Warner wrote: > Please forgive my lack of knowledge but for the life of me I can't figure > out what to install or how to install what I should be using. I'm using > VS2015 Community edition where I'm attempting to create a WPF desktop > application for windows