I hava one table named device_statistics,it store device info of one app,the table create scrip is:
CREATE TABLE public.device_statistics
(
id character varying(255) COLLATE pg_catalog."default" NOT NULL,
abnormalcount integer,
appid character varying(32) COLLATE pg_catalog."default" NOT NULL,
inactivecount integer,
offlinecount integer,
onlinecount integer,
statisticstime date,
totalcount integer,
CONSTRAINT ods_device_statistics_pkey PRIMARY KEY (id)
)
when a device offline,I must update the offlinecount value,since totalcount=abnormalcount + inactivecount + offlinecount + onlinecount
so can I auto update totalcount value when abnormalcount,inactivecount,offlinecount or onlinecount updated.
for example:
before a device offline,the row like(only show we need):
appid offlinecount totalcount
test 10 32
when a device offline and I update the offlinecount value,I want the follow row like:
appid offlinecount totalcount
test 9 31
the value of totalcout is auto update,how to do?