IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 't_er_expensesharebill' AND KSQL_COL_NAME ='FSHARECOMPANYID')
ALTER TABLE t_er_expensesharebill ADD (FSHARECOMPANYID BIGINT DEFAULT 0 NOT NULL);

/**
update t_er_expensesharebill as bill
set fsharecompanyid = t.fentrycostcompanyid
    from (
	select a.fid, a.fentrycostcompanyid from t_er_expensesharedetail as a
	join (select fid, min(fseq) as fseq from t_er_expensesharedetail group by fid) as b
	on a.fid = b.fid and a.fseq = b.fseq
	) as t
where bill.fid = t.fid;
 **/