Re: [sqlite] Window functions?

2014-08-26 Thread Wiktor Adamski
On 2014-08-26 18:00, sqlite-users-requ...@sqlite.org wrote: SELECT employee_name, employee_id, salary, rank() OVER(PARTITION BY dept ORDER BY salary DESC), 100.0*salary/sum(salary) OVER (PARTITION BY dept) FROM employee; I don't know if the above is valid SQL or not. But is

Re: [sqlite] Finding rows with MIN(MTIME) for all IDs

2012-09-11 Thread Wiktor Adamski
With regular ISO window functions, one could typically write something along these lines: with DataSet as ( select foo.*, lag( 0, 1, 1 ) over ( partition by id order by time ) as is_lag fromfoo ) select * fromDataSet where DataSet.is_lag = 1 you're right. it

Re: [sqlite] Finding rows with MIN(MTIME) for all IDs

2012-09-11 Thread Wiktor Adamski
select id, a, min(mtime) over(partition by id order by mtime) m from tab qualify row_number() over(partition by id order by mtime) = 1 While using analytics would indeed be the best approach overall, these are sadly not supported in SQLite in any ways or forms. (For the record, if using

Re: [sqlite] Bug

2011-11-23 Thread Wiktor Adamski
> I believe OVER() is an Oracle-specific extension to SQL, not a > standard in any way. ISO/IEC 9075-2:2003: ::= OVER ___ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Re: [sqlite] Bug

2011-11-23 Thread Wiktor Adamski
> Apparently, using such a function in ORDER BY > clause alone doesn't make the statement aggregate (whether it should is > perhaps debatable) I suppose this may be in the standart. I'm 100% sure that this one is allowed by standart: ... ORDER BY avg(a) OVER() so likely ORDER BY avg(a) is also

Re: [sqlite] Bug

2011-11-23 Thread Wiktor Adamski
>   In the first query, there is an aggregate in the result set, so an >   implicit GROUP BY is used.  The ORDER BY is meaningless, but not an >   error (and could be more easily written "ORDER BY 1"; see below). The order is not meaningless. It can return an error or do nothing. If aggregate in

[sqlite] Bug

2011-11-23 Thread Wiktor Adamski
SQLite version 3.7.9 2011-11-01 00:52:41 Enter ".help" for instructions Enter SQL statements terminated with a ";" sqlite> create table t(a); sqlite> select avg(a) from t order by avg(a); -- order by aggregate possible sqlite> select 1 from t order by a; -- order by column not in result possible

Re: [sqlite] Big FLOAT bug

2011-10-07 Thread Wiktor Adamski
> Changing the 2 "15g" entries in sqlite3.c to "16g" corrects this problem. 15 > digits is all that is guaranteed but the vast majority of 16-digit values are > representable. > > Is this a valid solution?  Or are there other side effects? It should be ok. However there's another bug that will

[sqlite] Big FLOAT bug

2011-10-05 Thread Wiktor Adamski
SQLite version 3.7.8 2011-09-19 14:49:19 Enter ".help" for instructions Enter SQL statements terminated with a ";" sqlite> create table t(a float); sqlite> insert into t values(1125899906842624); sqlite> select a = cast(cast(a as text) as float) from t; 0 Yes, I know - 16 digits. But

Re: [sqlite] Read only scaling optimization

2011-08-10 Thread Wiktor Adamski
Look at disc transfer. With 16 queries in one thread on single disc, disc may be accesed linearly (depeding on query). With 16 threads accesing disc at the same time linear disc access is impossible (however os may do some prefetching) and queries will by slower. You may try increasing page size -

Re: [sqlite] Need Help! -- SQlite database on server

2011-08-05 Thread Wiktor Adamski
http://www.sqlite.org/cvstrac/wiki?p=SqliteNetwork ___ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Re: [sqlite] sqlite seems to hang while indexing

2011-06-16 Thread Wiktor Adamski
> I was trying to create an index on an integer column in a very large > table with over 400,000,000 rows on an Ubuntu ... I > increased the cache size to 2 but to no avail. That's only 200M of cache and your table is much larger. Sqlite can't index/sort efficiently lare data on disc -

Re: [sqlite] Bug

2011-02-23 Thread Wiktor Adamski
>   In short, you cannot assume conditions are processed left-to-right, >   including JOIN conditions.   I admit that i haven't checked the snadart but I did check other engines and they evaluate from left to right. I think that long time ago I'v read in a standart that 3 table join is basicly

Re: [sqlite] Bug

2011-02-23 Thread Wiktor Adamski
> If you join > tables which have the same column names, you need to use the table names. You are right, but joined tables don't have the same column names. SELECT * FROM t1 JOIN t2 ON a = b -- there is only one 'a' and that select is correctly implemented SELECT * FROM t1 JOIN t2 ON a = b JOIN

[sqlite] Bug

2011-02-23 Thread Wiktor Adamski
SQLite version 3.7.5 Enter ".help" for instructions Enter SQL statements terminated with a ";" sqlite> CREATE TABLE t1 (a INT); sqlite> CREATE TABLE t2 (b INT); sqlite> CREATE TABLE t3 (a INT); sqlite> SELECT * FROM t1 JOIN t2 ON t1.a = t2.b AND a /* obviously t1.a */ != 1 JOIN t3 ON t1.a = t3.a;

Re: [sqlite] Slowdown when switching from Version 3.2.5 to 3.7.4

2010-12-17 Thread Wiktor Adamski
There is a lot more synchronization in 3.7.4. If you disable it new version may be faster. ___ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

[sqlite] group_concat + distinct

2010-09-22 Thread Wiktor Adamski
SQLite version 3.7.2 Enter ".help" for instructions Enter SQL statements terminated with a ";" sqlite> create table t(a); sqlite> select group_concat(distinct a) from t; sqlite> select group_concat(distinct a, ',') from t; Error: DISTINCT aggregates must have exactly one argument Both queries

[sqlite] Bug

2010-05-25 Thread Wiktor Adamski
SQLite version 3.6.23.1 Enter ".help" for instructions Enter SQL statements terminated with a ";" sqlite> create table t(a int); sqlite> insert into t values(1); sqlite> select 0 where 0; sqlite> update t set a = (select 0 where 0); sqlite> select * from t; sqlite> select 0 limit 0; sqlite>

Re: [sqlite] Berkeley DB adds SQL using SQLite API !!

2010-03-31 Thread Wiktor Adamski
> There were many problems with   > that approach: ... > (3) Each table and index is in a   > separate file so your "database" was a directory full of files instead   > of a single file This one is not a problem. Actually I don't see how 1 file is better than 1 directory. For example mac

Re: [sqlite] Bug

2009-12-31 Thread Wiktor Adamski
> Already fixed.  Seehttp://www.sqlite.org/src/info/f74beaabde I'm might be wrong because I didn't check with the newest binary, but if I remember correctly this fix will compare t3.a to t1.a (instead of t2.a). So it will produce different results (first select will be 1|2 and second will be

[sqlite] Bug

2009-12-31 Thread Wiktor Adamski
SQLite version 3.6.21 Enter ".help" for instructions Enter SQL statements terminated with a ";" sqlite> create table t1(a int); sqlite> create table t2(a int); sqlite> create table t3(a int); sqlite> insert into t1 values(1); sqlite> insert into t2 values(2); sqlite> insert into t3 values(1);

[sqlite] Bug: ambiguous column name

2009-12-23 Thread Wiktor Adamski
There's no reason for following error: SQLite version 3.6.21 Enter ".help" for instructions Enter SQL statements terminated with a ";" sqlite> .headers ON sqlite> create table t1(a int); sqlite> create table t2(a int); sqlite> create table t3(a int); sqlite> insert into t1 values(1); sqlite>

[sqlite] USING bug

2009-12-08 Thread Wiktor Adamski
SQLite version 3.6.21 Enter ".help" for instructions Enter SQL statements terminated with a ";" sqlite> create table t1(a int); sqlite> create table t2(a int); sqlite> create table t3(a int, b int); sqlite> insert into t1 values(1); sqlite> insert into t3 values(1, 1); sqlite> select * from t1

Re: [sqlite] problem using random() in queries

2008-08-30 Thread Wiktor Adamski
> Richard, Before you "fix" it, I'm not convinced it is broken. > > >From MS SQL server > > create table _names (N varchar(5)); > insert into _names values('a'); > insert into _names values('b'); > insert into _names values('c'); > insert into _names values('d'); > insert into _names values('e');