>James K. Lowden, on Tuesday, February 12, 2019 11:39 AM, wrote... >>On Tue, 12 Feb 2019 15:05:29 +0000 >>Jose Isaias Cabrera <jic...@outlook.com> wrote: >> >>> >SELECT * From t WHERE datestamp = "20190208" >>> >>> Ok, Simon, I'll bite; :-) Imagine this table: >>> >>> t (n INTEGER PRIMARY KEY, a, b, c, d, e, idate) >> >>That's better. >> >>> how would I find the differences in the fields based on the different >>> idate? >> >>select ... >>from t as now join t as then >>on now.idate = '20190208' >>and then.idate = '20190207' -- note single quotes >>and ... -- other things that match >>where ... --- things that don't match >> >>Can't be more specific than that when the question is "find the >>differences". > >No, this is great. This is great, thanks.
One last question on this... Imagine this scenario... create table t (n INTEGER PRIMARY KEY, a, b, c, d, e, idate); insert into t (a, b, c, d, e, idate) values ('p001', 1, 2, 'n', 4, '2019-02-11'); insert into t (a, b, c, d, e, idate) values ('p002', 2, 2, 'n', 4, '2019-02-11'); insert into t (a, b, c, d, e, idate) values ('p003', 3, 2, 'n', 4, '2019-02-11'); insert into t (a, b, c, d, e, idate) values ('p004', 4, 2, 'y', 4, '2019-02-11'); insert into t (a, b, c, d, e, idate) values ('p005', 5, 2, 'y', 4, '2019-02-11'); if I am inserting new records into the table, and there is a field, say "d", I want to keep the last value of that field for the last inserted record, how can I do this? I am trying this, insert into t (a, b, c, d, e, idate) values ('p001', 1, 2, SELECT d FROM t WHERE a = 'p001' AND max(idate), 4, '2019-02-12'); insert into t (a, b, c, d, e, idate) values ('p002', 1, 2, SELECT d FROM t WHERE a = 'p002' AND max(idate), 4, '2019-02-12'); insert into t (a, b, c, d, e, idate) values ('p003', 1, 2, SELECT d FROM t WHERE a = 'p003' AND max(idate), 4, '2019-02-12'); insert into t (a, b, c, d, e, idate) values ('p004', 1, 2, SELECT d FROM t WHERE a = 'p004' AND max(idate), 4, '2019-02-12'); insert into t (a, b, c, d, e, idate) values ('p005', 1, 2, SELECT d FROM t WHERE a = 'p005' AND max(idate), 4, '2019-02-12'); insert into t (a, b, c, d, e, idate) values ('p006', 1, 2, SELECT d FROM t WHERE a = 'p006' AND max(idate), 4, '2019-02-12'); -- new But, of course, it's not working. I get, Error: near "SELECT": syntax error Thougths? thanks. _______________________________________________ sqlite-users mailing list sqlite-users@mailinglists.sqlite.org http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users