// Selection of image data in the multimedia table
Select substring(SPATH from 6 for 200) Path , sorgfilename dest,1 sgroup FROM
MULTIMEDIA join stock on wrefid = wstockid where WREFID = <@WSTOCKID@> and STYPE = 'STOCK' and (SPATH like 'link:%' or SPATH like 'file:%') 
and (SGROUP = 'products_image' )
union
Select substring(SPATH from 6 for 200) Path , sorgfilename dest,2 sgroup FROM
MULTIMEDIA join stock on wrefid = wstockid where WREFID = <@WSTOCKID@> and STYPE = 'STOCK' and (SPATH like 'link:%' or SPATH like 'file:%') 
and (  SGROUP = 'products_subimage1' )

union
Select substring(SPATH from 6 for 200) Path , sorgfilename dest,3 sgroup FROM
MULTIMEDIA join stock on wrefid = wstockid where WREFID = <@WSTOCKID@> and STYPE = 'STOCK' and (SPATH like 'link:%' or SPATH like 'file:%') 
and ( SGROUP = 'products_subimage2')

union
Select substring(SPATH from 6 for 200) Path , sorgfilename dest,4 sgroup FROM
MULTIMEDIA join stock on wrefid = wstockid where WREFID = <@WSTOCKID@> and STYPE = 'STOCK' and (SPATH like 'link:%' or SPATH like 'file:%') 
and (   SGROUP = 'products_subimage3' )

union
Select substring(SPATH from 6 for 200) Path , sorgfilename dest,5 sgroup FROM
MULTIMEDIA join stock on wrefid = wstockid where WREFID = <@WSTOCKID@> and STYPE = 'STOCK' and (SPATH like 'link:%' or SPATH like 'file:%') 
and (   SGROUP = 'products_subimage4' )

union
Select substring(SPATH from 6 for 200) Path , sorgfilename dest,6 sgroup FROM
MULTIMEDIA join stock on wrefid = wstockid where WREFID = <@WSTOCKID@> and STYPE = 'STOCK' and (SPATH like 'link:%' or SPATH like 'file:%') 
and (   SGROUP = 'products_subimage5' )
union
Select substring(SPATH from 6 for 200) Path , sorgfilename dest,7 sgroup FROM
MULTIMEDIA join stock on wrefid = wstockid where WREFID = <@WSTOCKID@> and STYPE = 'STOCK' and (SPATH like 'link:%' or SPATH like 'file:%') 
and (   SGROUP = 'products_subimage6' )