CREATE VIEW vImportKcRpt AS Select K.id,k.ContractNo,k.CZState, (select enumvaluename from tsysenumvalue where enumtypeid=8 and enumvalueid=K.czstate) as CZRf,k.InNum,k.OutNum, k.KFstate,(select enumvaluename from tsysenumvalue where enumtypeid=9 and enumvalueid=k.KFstate) as KFRf, K.CZdate,K.[text],m.seller,m.buyer,m.Billno,m.Vessel,m.Voyage,m.Sailingdate,m.ArrivalDate,m.ContainerNo,m.SealNo, c.name as goodname,c.cargoinfo_id,(select code from import_cargoinfo where import_cargoinfo.id=c.cargoinfo_id) as cargoinfoRf, c.cargociq_id,(select ciqcode from import_cargociq where import_cargociq.id=c.cargociq_id) as cargociqRf from [Import_KC] K left join import_cargo c on c.id=k.cargo_id left join Import_main m on m.ContractNo=k.ContractNo