Re: [sqlite] AVG Function HowTo

2019-12-28 Thread Keith Medcalf
create table earnings (tdate text not null, amount real not null); create table expenses (tdate text not null, amount real not null); insert into earnings values ('2010-01-01', 4000.00), ('2010-01-15', 4000.00); insert into expenses values ('2010-01-02', 2500.00), ('2010-01-05', 2.00),

Re: [sqlite] AVG Function HowTo

2019-12-28 Thread Keith Medcalf
The description makes no sense. So lets say on the 1st of a Month you have an "Earnings" of $4,000. On the 2nd of the month you have an "expense" of $2,500. On the 5th of the month you have an "expense" of $2.00. On the 15th of the month you have an "Earnings" of $4000. So the "average"

Re: [sqlite] SQL help

2019-12-28 Thread Simon Slavin
On 28 Dec 2019, at 10:49pm, Barry Smith wrote: > Why does section 6.4.3.a.i of that linked standard not apply to his sub > select? I was thinking of the matching on (3,3), but perhaps you are right. ___ sqlite-users mailing list

Re: [sqlite] SQL help

2019-12-28 Thread Barry Smith
Why does section 6.4.3.a.i of that linked standard not apply to his sub select? In the quote below, CR is Column Reference, CN is Column Name. 3) If CR does not contain a , then CR shall be contained within the scope of one or more s or s whose associated tables include a column

Re: [sqlite] SQL help

2019-12-28 Thread Simon Slavin
On 28 Dec 2019, at 5:19pm, Barry Smith wrote: > Is not identifier resolution (search in the current scope first then step > out) part of the SQL standard? The way the SELECT statements are nested in the question is itself non-standard in any version of SQL I can cite in this message. > Damn

Re: [sqlite] SQL help

2019-12-28 Thread Barry Smith
Is not identifier resolution (search in the current scope first then step out) part of the SQL standard? Damn closed standards and their inability to check without paying through the nose. Even if not, and this is in fact undocumented, I would be amazed if it changed, purely for the sheer

Re: [sqlite] AVG Function HowTo

2019-12-28 Thread Barry Smith
SQL is a declarative language, not a procedural one. Therefore I find it helps to think in declarative terms rather than procedural. What that means practically in this case is don’t think in terms of loops. Think about what you want, and think about how your data is related. I don’t entirely

Re: [sqlite] SQL help

2019-12-28 Thread x
Thanks Simon. ___ sqlite-users mailing list sqlite-users@mailinglists.sqlite.org http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users

Re: [sqlite] AVG Function HowTo

2019-12-28 Thread Luuk
On 28-12-2019 13:07, Csanyi Pal wrote: Hi, I have attached here the exported sql file of my little sqlite database. I am a newbe in the sqlite language so I ask here only an advice in which direction to go, eg. which functions of sqlite language to use to achieve my goal? SQList is able

[sqlite] Debug Assertion Bug in Sqlite

2019-12-28 Thread Yongheng Chen
Hi, We found some assertion bugs in sqlite. Here’s the pocs: #1 — CREATE TABLE v0 ( v1 , v2 PRIMARY KEY ON CONFLICT REPLACE ) ; CREATE TEMP TRIGGER x BEFORE INSERT ON v0 BEGIN INSERT INTO v0 ( v1 ) VALUES ( 10 ) ; END ; CREATE VIRTUAL TABLE v3 USING rtree ( v4 AS( v2 = 'MED PACK' ) , v5 AS( v2

[sqlite] Assertion failed in Sqlite

2019-12-28 Thread Bigthing Do
Hi, We found a assertion bug in sqlite3, here is the poc: — CREATE TABLE v0 ( v1 CHAR(25) , v2 INTEGER UNIQUE ON CONFLICT ABORT NOT NULL PRIMARY KEY CHECK( datetime ( lower ( v2 ) , NOT lower ( v1 / 1 ) ) == 'MED PACK' NOT LIKE v2 ) ) ; CREATE TRIGGER alias AFTER INSERT ON v0 BEGIN INSERT OR

Re: [sqlite] SQL help

2019-12-28 Thread Simon Slavin
On 28 Dec 2019, at 3:46pm, x wrote: > In the embedded select it takes c from the outer table t1 but doesn’t flag > ‘ambiguous column’ for b in the embedded select. Is it standard that tables > at the same level are searched first for the column and tables from the > surrounding levels are

[sqlite] SQL help

2019-12-28 Thread x
Consider the following sqlite> create table t1(a int, b int, c int); sqlite> create table t2(a int, b int); sqlite> insert into t1 values (1, 2, 3); sqlite> insert into t2 values (3, 4); sqlite> select a,(select b, c from t2 where t2.a=t1.a)=(3,3) from t1; 1| In the embedded select it takes c

Re: [sqlite] AVG Function HowTo

2019-12-28 Thread Csanyi Pal
2019. 12. 28. 13:07 keltezéssel, Csanyi Pal írta: Hi, I have attached here the exported sql file of my little sqlite database. I am a newbe in the sqlite language so I ask here only an advice in which direction to go, eg. which functions of sqlite language to use to achieve my goal? My

[sqlite] AVG Function HowTo

2019-12-28 Thread Csanyi Pal
Hi, I have attached here the exported sql file of my little sqlite database. I am a newbe in the sqlite language so I ask here only an advice in which direction to go, eg. which functions of sqlite language to use to achieve my goal? My issue is the following. So far my database has two