SELECT d_style_no,
Sum(Nvl(cutting_quantity,0)) cutqty,
ok.ok d_style_no,
d_style.size_1,
d_style.size_2,
d_style.size_3,
d_style.size_4,
s.stqty,
d_style.size_5,
d_style.size_6,
d_style.size_7,
d_style.size_8,
d.qty,
retqty,
d_style_no,
d_cutting.cutting_color_name,
Nvl(s.st1,0) - Nvl(d.st1,0) + Nvl(r.st1,0) AS "Size1",
Nvl(s.st2,0) - Nvl(d.st2,0) + Nvl(r.st2,0) AS "Size2",
Nvl(s.st3,0) - Nvl(d.st3,0) + Nvl(r.st3,0) AS "Size3",
Nvl(s.st4,0) - Nvl(d.st4,0) + Nvl(r.st4,0) AS "Size4",
Nvl(s.st5,0) - Nvl(d.st5,0) + Nvl(r.st5,0) AS "Size5",
Nvl(s.st6,0) - Nvl(d.st6,0) + Nvl(r.st6,0) AS "Size6",
Nvl(s.st7,0) - Nvl(d.st7,0) + Nvl(r.st7,0) AS "Size7",
Nvl(s.st8,0) - Nvl(d.st8,0) + Nvl(r.st8,0) AS "Size8",
Nvl(s.st1,0) - Nvl(d.st1,0) + Nvl(r.st1,0) + Nvl(s.st2,0) - Nvl(d.st2,0) + Nvl(r.st2,0) + Nvl(s.st3,0) - Nvl(d.st3,0) + Nvl(r.st3,0) + Nvl(s.st4,0) - Nvl(d.st4,0) + Nvl(r.st4,0) + Nvl(s.st5,0) - Nvl(d.st5,0) + Nvl(r.st5,0) + Nvl(s.st6,0) - Nvl(d.st6,0) + Nvl(r.st6,0) + Nvl(s.st7,0) - Nvl(d.st7,0) + Nvl(r.st7,0) + Nvl(s.st8,0) - Nvl(d.st8,0) + Nvl(r.st8,0) AS "Total"
FROM d_style,
d_cutting,
(SELECT imange ok
FROM d_style) ok,
(SELECT d_stitch_style_no sti1,
Sum(Nvl(size_1,0)) st1,
Sum(Nvl(size_2,0)) st2,
Sum(Nvl(size_3,0)) st3,
Sum(Nvl(size_4,0)) st4,
Sum(Nvl(size_5,0)) st5,
Sum(Nvl(size_6,0)) st6,
Sum(Nvl(size_7,0)) st7,
Sum(Nvl(size_8,0)) st8,
Sum(Nvl(stitch_quantity,0)) stqty
FROM d_stitch
WHERE d_stitch_date BETWEEN Nvl(:date_from,d_stitch_date) AND Nvl(:date_to,d_stitch_date)
GROUP BY d_stitch_style_no) s,
(SELECT d_dispatch_style_no dis1,
Sum(Nvl(size_1,0)) st1,
Sum(Nvl(size_2,0)) st2,
Sum(Nvl(size_3,0)) st3,
Sum(Nvl(size_4,0)) st4,
Sum(Nvl(size_5,0)) st5,
Sum(Nvl(size_6,0)) st6,
Sum(Nvl(size_7,0)) st7,
Sum(Nvl(size_8,0)) st8,
Sum(Nvl(dispatch_quantity,0)) qty
FROM d_dispatch
WHERE d_dispatch_date BETWEEN Nvl(:date_from,d_dispatch_date) AND Nvl(:date_to,d_dispatch_date)
GROUP BY d_dispatch_style_no) d,
(SELECT d_return_style_no ret1,
Sum(Nvl(size_1,0)) st1,
Sum(Nvl(size_2,0)) st2,
Sum(Nvl(size_3,0)) st3,
Sum(Nvl(size_4,0)) st4,
Sum(Nvl(size_5,0)) st5,
Sum(Nvl(size_6,0)) st6,
Sum(Nvl(size_7,0)) st7,
Sum(Nvl(size_8,0)) st8,
Sum(return_quantity) retqty
FROM d_return
WHERE d_return_date BETWEEN Nvl(:date_from,d_return_date) AND Nvl(:date_to,d_return_date)
GROUP BY d_return_style_no) r
WHERE d_cutting.d_cutting_style_no (+) = d_style.d_style_no
AND r.ret1 (+) = d_style.d_style_no
AND d.dis1 (+) = d_style.d_style_no
AND s.sti1 (+) = d_style.d_style_no
AND d_style_no BETWEEN Nvl(:Style_from,d_style_no) AND Nvl(:style_to,d_style_no)
AND d_catagory_name = Nvl(:Catagory,d_catagory_name)
GROUP BY d_style_no,
d_style_no,
d_style.size_1,
d_style.size_2,
d_style.size_3,
d_style.size_4,
s.stqty,
d_style.size_5,
d_style.size_6,
d_style.size_7,
d_style.size_8,
d.qty,
retqty,
d_style_no,
d_cutting.cutting_color_name,
s.st1,
s.st2,
s.st3,
s.st4,
s.st5,
s.st6,
s.st7,
s.st8,
d.st1,
d.st2,
d.st3,
d.st4,
d.st5,
d.st6,
d.st7,
d.st8,
r.st1,
r.st2,
r.st3,
r.st4,
r.st5,
r.st6,
r.st7,
r.st8,
ok