varsql=@"update a set a.StartedTime = (case when (select Max(LoadTime) from B3Sale_CustomerAccept b where b.CustomerDealer_ID = a.ID and BillState = 20) is null then a.CreateTime else (select Max(LoadTime) from B3Sale_CustomerAccept b where b.CustomerDealer_ID = a.ID and BillState = 20) end) from B3Sale_Customer a where IsDealers = 1";