Group By in DB2 Stage and Ref from hash File
Posted: Fri Nov 03, 2006 9:50 am
Hi,
I have a Hash File which contains 8 fields:
{F1 #, F2 #,F3 #,F4 #}
and another DB2 Rec, TAB1{f1#,f2#,f3#,f4#,f5#,F6#,f7,f8....}
(Fn # and fn #represents Key Fields)
Now my reqmt is output as of these queries:
SELECT f1#,f2#,f3#,MAX(f4#),f5#,MAX(f6#)
FROM TAB1
WHERE f1#=Value1 AND f2# = Value2 AND f3# = Value3 AND f4# = Value4
GROUP BY f1#,f2#,f3#,f4#,f5#,F6#;
Another form of query is:
SELECT f1#,f2#,f3#,MAX(f4#),f5#,MAX(f6#)
FROM TAB1
GROUP BY f1#,f2#,f3#,f4#,f5#,F6#
HAVING f1#=Value1 AND f2# = Value2 AND f3# = Value3 AND f4# = Value4.
The Value1 , Value2, Value3 adn Value4 are the values of F1#,F2#,F3#,F4# of the Hash File.
please explain how to achieve it in my job design.
Thx.
I have a Hash File which contains 8 fields:
{F1 #, F2 #,F3 #,F4 #}
and another DB2 Rec, TAB1{f1#,f2#,f3#,f4#,f5#,F6#,f7,f8....}
(Fn # and fn #represents Key Fields)
Now my reqmt is output as of these queries:
SELECT f1#,f2#,f3#,MAX(f4#),f5#,MAX(f6#)
FROM TAB1
WHERE f1#=Value1 AND f2# = Value2 AND f3# = Value3 AND f4# = Value4
GROUP BY f1#,f2#,f3#,f4#,f5#,F6#;
Another form of query is:
SELECT f1#,f2#,f3#,MAX(f4#),f5#,MAX(f6#)
FROM TAB1
GROUP BY f1#,f2#,f3#,f4#,f5#,F6#
HAVING f1#=Value1 AND f2# = Value2 AND f3# = Value3 AND f4# = Value4.
The Value1 , Value2, Value3 adn Value4 are the values of F1#,F2#,F3#,F4# of the Hash File.
please explain how to achieve it in my job design.
Thx.