create view godownEntryIdSerialNumber as select ge.id,mge.type,mge.serialNumber from GodownEntry ge inner join (select id,type,serialNumber from GodownEntry) mge on ge.sourceId = mge.id union all select id,type,serialNumber from GodownEntry where sourceId is null or sourceId = 0