Can you use something along the lines of this?

insert into max_value select value as "value" from source_table order by value 
desc limit 1;

Shane Dev Sent: Wednesday, January 10, 2018 11:49 AM
To: SQLite mailing list <>
Subject: [sqlite] Is it possible to conditionally insert a record?


sqlite> create table source_table(value);
sqlite> create table max_value(max_value);
sqlite> insert into max_value select max(value) from source_table;
sqlite> select * from table_max_value;


How can the maximum value of column source_table.value be inserted into
max_value only if there are records in source_table? (If source_table is
empty, nothing should be inserted into max_value, not even a NULL)

This message, and any attachments, is for the intended recipient(s) only, may 
contain information that is privileged, confidential and/or proprietary and 
subject to important terms and conditions available at   If you are not the intended 
recipient, please delete this message.
sqlite-users mailing list

Reply via email to