Skip to content
Advertisement

Tag: sqlite

SQL want efficient query to SELECT columnA, columnB FROM table1 WHERE both columnA, columnB are in columnC FROM table2 WHERE columndD > value

I’m searching for a more efficient method to accomplish something that I’ve already solved with a few different SQL statements. The problem: I have two tables a transactions table, and an accounts table The transactions table has columns that look like: acct_sending acct_receiving amount tx_datetime 100 101 10 yyyy-mm-dd hh-mm-ss 101 100 5 yyyy-mm-dd hh-mm-ss 101 200 1 yyyy-mm-dd hh-mm-ss

How to create a trigger on table A that inserts/updates entity in table B?

I have tables TableAAA, TableBBB, TableCCC and TableCollected. The AAA/BBB/CCC tables have a DateTime column: I’d like to have a 1-1 trigger on each table that runs after inserting/updating. It should save the biggest DateTime from given table into the TableCollected table. So if TableAAA table contains 3 rows with dates 1980-01-01, 1990-01-01 and 2010-01-01 then in TableCollected I’d have

SQLite: optimize query with union

This is my table definition: And this is my query + plan: So the index is used, but there is still a scan and a b-tree involved in the order by. I tried getting rid of them by adding more indexes, but I don’t get it working. Any ideas of an index which gets rid of the scan? Answer Your

Condition to SUM previous values – SQLite

My following SQLite database: Explaining brazilian tax income: a) if I have loss, I don’t need to pay any tax (e.g.: January) b) negative results can be subtracted from the next month positive outcome (e.g.: in February, instead of paying the full tax for $ 5942, the tax can be applied only to (5942 – 3200) = 2742. c) if

Advertisement