View previous topic :: View next topic
|
Author |
Message |
dharmendra_kp
New User
Joined: 10 Mar 2005 Posts: 33 Location: Lewiston
|
|
|
|
Hi! ALL,
1 CAN ANY ONE EXPLAIN THE DEFERACE BETBEEN KEYWORD 'COPY' & 'INCLUDE' ?
2> WRITE A SQL QUERY TO GET Nth Largest value of a column from a DB2 table ? n > 15.
THANKS IN ADVANCE |
|
Back to top |
|
|
serious_mainframes
New User
Joined: 10 Mar 2005 Posts: 2
|
|
|
|
copy used in cobol for copying some data what we want from ps or pds
include is used in db2 to include a communication areas and any dclgen members |
|
Back to top |
|
|
ovreddy
Active User
Joined: 06 Dec 2004 Posts: 211 Location: Keane Inc., Minneapolis USA.
|
|
|
|
Hi Dharmendra,
COPY is used to copy the contents of a Copy book ( which contains COBOL statements) into athe COBOL program.
INCLUDE is used to copy the contents of a COPYBOOK generated by DCLGEN for host variable declarations.
SELECT MAX(COLUMN) FROM TAB A WHERE 15=(SELECT COUNT(*) FROM TAB B WHERE A.COL<=B.COL);
Please search the FORUM before posting, Avoid posting the same ques twice.
Bye,
Reddy. |
|
Back to top |
|
|
mcmillan
Site Admin
Joined: 18 May 2003 Posts: 1210 Location: India
|
|
|
|
You are right Reddy, But a small correction, if you don't mind!
'COPY' and 'INCLUDE' (I believe it's not JCL Include) do the same function. You can Copy any set of statements using this statements.
But COPY Statement is honored by the Cobol Compiler while INCLUDE statement is identified by the DB2 PreCompiler.
You can use INCLUDE statement to copy the statements, not generated by DCLGEN also. |
|
Back to top |
|
|
ovreddy
Active User
Joined: 06 Dec 2004 Posts: 211 Location: Keane Inc., Minneapolis USA.
|
|
|
|
Hi McMillan,
I agree with you. Thanks for correction
Thanks,
Reddy |
|
Back to top |
|
|
kiranchinthapalli
New User
Joined: 13 Mar 2005 Posts: 1
|
|
|
|
Hi,
the main difference between INCLUDE and COPY is that they perform the same operation but
INCLUDE------> It will expand only at the time of DB2 pre-compilation &
COPY----------->It will expand only at the time of COBOL compilation
bye.
kiran. |
|
Back to top |
|
|
dharmendra_kp
New User
Joined: 10 Mar 2005 Posts: 33 Location: Lewiston
|
|
|
|
hi! ALL,
thanks guys for answering about COPY & INCLUDE!
I would like to thank REDDY & KIRAN particularly for Answering both the questions.
I would like to MAKE A CORRECTION TO THE ANSWERE OF THE 2ND QUESTION ie. which i got after working on your code.
TO GET THE NTH LARGEST VALUE OF A COLUMN FROM A DB2 TABLE, where n > 15 ( becouse there can be a max of 15 level of non co-related subquery.
for if there is redundancy in the column that is if the column has more than one value which is equal to the nth largest THE MODIFIED CODE SHULD BE SOMETHING LIKE THIS:
Code: |
SELECT * FORM (SELECT DISTINCT col1, col2, ... colx FROM TAB)A WHERE (SELECT COUNT(*) FROM ( SELECT DISTINCT col1, col2, ...colx FROM TAB)B WHERE A.col1 <= B.col1) =n; |
But still I am very sceptical abt its performance issues. ANY ONE HAVING ANY BETTER METHOD PLZ SHARE.
Thank u. |
|
Back to top |
|
|
i413678 Currently Banned Active User
Joined: 19 Feb 2005 Posts: 112 Location: chennai
|
|
|
|
hi dharmendra,
can you please explain the query how it works?
thanx in advance.
pavan
work is worship & duty is god |
|
Back to top |
|
|
|