select substring(b.IMP_EXTID {If SQL Server},{else}from{endif} 6 {If SQL Server},{else}for{endif} 12) GRP from IMP_LINK b  join
 STOCK_MULTIGROUP a on a.WGROUPID = b.WGROUPID   and b.imp_sourceid =<@SOURCEID@>
where  a.WStockid = <@WSTOCKID@>
UNION
select substring(b.IMP_EXTID {If SQL Server},{else}from{endif} 6 {If SQL Server},{else}for{endif} 12) from IMP_LINK b  join
 stock a on 
 b.WGROUPID = a.WReportingGroup1id  and b.imp_sourceid =<@SOURCEID@>
where a.WStockid = <@WSTOCKID@>
