Can we use group-by clause in sub-query? If 'yes'
means,Will it be executed successfully or else If 'no'
means why should we not using that method? Give me your
suggestion please....

Answer Posted / db2222

Yes, we can use the Group-by in the subquery.
-----EX----
SELECT DISTINCT(A.IDN), B.NAME,B.EFF_DATE, B.CNCRCY_TMSTMP
FROM
Table1 A,
Table2 B,
Table3 C
WHERE
A.IDN = C.IDN
AND C.IDN = B.ALIAS_IDN
AND A.IDN IN
(SELECT IDN
FROM Table4
GROUP BY CUSACC_IDN
HAVING COUNT(*) > 1
)
WITH UR;

Is This Answer Correct ?    0 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

I understand Join always perform better than subqueries. Then what is the advantage/use of Subqueries/correlated subqueries etc.,in DB2 programming.Please explain.

1841


For a db2 column that is being defined as decimal (11, 2), discuss the cobol picture clause.

847


What is rct?

968


When reorg is used?

848


What is the maximum number of columns in a db2 table?

976


What are the different types of base tables?

763


What is db2 optimizer?

986


How many databases can be created inside an instance in db2 ?

806


What is ibm db2 used for?

817


What is bind package and plan in db2?

797


Cursors can be declared in both working-storage & procedure division, agreed. But is there any difference? If could you please suggest what is the difference

967


what are bind concepts in db2 cobol?

822


Who uses db2?

753


can any one provide me the link for the db2 v7 & db2 v8 manual for Z/os? i need to know about the syntax of REORG in both versions & need to know the difference as well

2002


What are the full forms of spufi and dclgen and why are they used?

841