SELECT a.COLUMN_VALUE saledate, dd.article, dd.loc, 0 q, 0 summ2 FROM table (vit_dat_rang.gen_range (TO_DATE ('01.06.2013', 'dd.mm.yyyy'), TO_DATE ('31.06.2013', 'dd.mm.yyyy'))) a, ( SELECT /*+ PARALLEL(D, 2) */ DISTINCT d.article, DECODE (d.salelocationto, -2, d.salelocationfrom, d.salelocationto) loc FROM fvmaprep d WHERE d.saledate < TO_DATE ('01.07.2013', 'dd.mm.yyyy') AND d.rectype = NVL(1,UID) ) dd;