View previous topic :: View next topic
|
Author |
Message |
samchris
New User
Joined: 31 May 2005 Posts: 26 Location: pune
|
|
|
|
in xpediter i marked "b" in 15 where its starts debugging?
cobol:
write binary search code using indexs ?can anyone give me some code example ?
db2:
how to calulate second highest salary in employee table? |
|
Back to top |
|
|
thanooz
New User
Joined: 28 Jun 2005 Posts: 99
|
|
|
|
hi samchris,
if you are given "b" in 15 also it starts debuging from first line onward's then u press f12 means then only it will goes to that line.
for db2:
select sal from emp a where 2 = (select count(*) from emp b where a.emp <= b.emp)
thank's
thanooz. |
|
Back to top |
|
|
samchris
New User
Joined: 31 May 2005 Posts: 26 Location: pune
|
|
|
|
hello sir,
thanks for ur reply sir.
regards
chris |
|
Back to top |
|
|
bright_skull
New User
Joined: 22 May 2006 Posts: 7 Location: Bangalore
|
|
|
|
For DB2:
I tried executing the query provided by Thanooz and verified it. The Query worked but took very long time compared to my query.
I also happened to come across the same question in one of the interviews I appeared.
Definitely I couldn't answer properly, but had come half way thru' and the interviewer was keen on getting a 'single' second highest value and not the sequence in desc order. The Query is some what simple also. I've tested this properly.
Here it goes:
SELECT EMPSAL FROM EMPTABLE
WHERE EMPSAL <
(SELECT MAX(EMPSAL) FROM EMPTABLE)
ORDER BY EMPSAL DESC
FETCH FIRST ROW ONLY
Explanation of the Query:
The Inner Query will return the Max value for Empsalary and the Outer Query will provide 'any' value less than the Max value in Descending order. So in order to limit it to one value that's the second highest, Use Fetch first row only.
|
|
Back to top |
|
|
sureshchoudey
New User
Joined: 16 Sep 2005 Posts: 12
|
|
|
|
SELECT EMPSAL FROM EMPTABLE
WHERE EMPSAL <
(SELECT MAX(EMPSAL) FROM EMPTABLE) |
|
Back to top |
|
|
Muthukumar.PLindia
New User
Joined: 03 Jul 2006 Posts: 51 Location: Chennai
|
|
|
|
Hi thanooz,
Could you please explain ur query |
|
Back to top |
|
|
bright_skull
New User
Joined: 22 May 2006 Posts: 7 Location: Bangalore
|
|
|
|
Hi Suresh,
What does your query do.... It will fetch all the rows of the EMPSAL column which are less than the Max EMPSAL. But do you know the requirement?? We need to get only the second Maximum EMPSAL...
Also Thanooz please explain how you got that query???
|
|
Back to top |
|
|
bright_skull
New User
Joined: 22 May 2006 Posts: 7 Location: Bangalore
|
|
|
|
Hi All,
I was thinking about the above questions again and again and came up with this simple logic.
The logic that I'll be putting down here can be used to get only the 3rd or 4th Max easily.. but this might eat up the resources as the joins are more.
For getting the second Max.
SELECT MAX(EMPSAL) FROM EMPTABLE
WHERE EMPSAL < (SELECT MAX(EMPSAL) FROM EMPTABLE).
Isn't this query simple compared to the previous 2 posted here???
|
|
Back to top |
|
|
Niranjan B Manjappa
New User
Joined: 02 Jan 2007 Posts: 2 Location: Pune
|
|
|
|
Can any one tell me how to set a break point in the middle of the perform
Eg perform i varying from 1 by 1 untill i>1000
I want top see the value of i =152.
I dnt want to press 152 times f9 and the value of i152
depends on the previous occurence.Do we hae any option for this |
|
Back to top |
|
|
ragganga
New User
Joined: 22 Jan 2007 Posts: 18 Location: bangalore
|
|
|
|
Hi Niranjan,
Just overide(change) the I value in the Top screen when the value is 1 to 152.
Regards
Raghu |
|
Back to top |
|
|
Niranjan B Manjappa
New User
Joined: 02 Jan 2007 Posts: 2 Location: Pune
|
|
|
|
Hi ,
Thanks for your reply.
I got the answer.
We can even use when i= 152 to set the break point.
Cheers
Niranjan |
|
Back to top |
|
|
azshukla
New User
Joined: 31 May 2006 Posts: 9 Location: Pune
|
|
|
|
And how would you do that niranjan?? |
|
Back to top |
|
|
prasadvrk
Active User
Joined: 31 May 2006 Posts: 200 Location: Netherlands
|
|
|
|
First one(B) is unconditional break point and second one is conditional break point which can be applied by keying in WHEN in the command line and supplying the variable name and the value for which you want to break. |
|
Back to top |
|
|
|