Search now from the first day of the month six months ago Date:
SELECT date('now','start of month','-6 month','0 day');
Search from the date six months ago now:
SELECT date('now','-6 month','0 day');
case when usage:
chestnut:
select case when a = "1" then "v" end from table;
or
select case a when "1" then "v" end from table;
Remember must use end wrap conditions, a set of multiple field case when statements can only be executed once, like this:
select case when name like "%a%" then replace(name,'a','A')
when name like "%b%" then replace(name,'b','B')
when name like "%c%" then replace(name,'c','C')
else name end as SB ,*
from table;
The purpose of this statement is the name field partial Alternatively, he can replace a, b, c in a
If you want to replace all such need a number of sets of replace ()
select replace(replace(replace(name,"a",A),"b","B"),"c","C") from table;
A lot of trouble, but the efficiency is very low under the circumstances a large amount of data
Date of addition and subtraction julianday ():
select julianday('now') - julianday('1776-07-04');