CASE conditional statement [message #243091] |
Wed, 06 June 2007 00:55  |
kc1982
Messages: 13 Registered: October 2006
|
Junior Member |
|
|
FOR i IN 1..4 LOOP
SELECT COUNT(*)
INTO v_student
FROM student_detail
WHERE grade IN (CASE WHEN i = 1 THEN 'F1'
WHEN i = 2 THEN 'F2'
WHEN i = 3 THEN 'F3'
WHEN i = 4 THEN 'F4','F5'
END);
dbms_output.put_line(Loop: '||i);
dbms_output.put_line('No of students is: '||v_student);
END LOOP;
There is no record returned when the loop goes to 4.
I want something like this
IF i = 4 THEN
SELECT COUNT(*)
FROM student_detail
WHERE grade IN ('F4','F5');
END IF;
I have no idea to solve the problem. I tried with
FOR i IN 1..4 LOOP
SELECT COUNT(*)
INTO v_student
FROM student_detail
WHERE grade IN (CASE WHEN i = 1 THEN 'F1'
WHEN i = 2 THEN 'F2'
WHEN i = 3 THEN 'F3'
WHEN i = 4 THEN '''F4'',''F5'''
END);
dbms_output.put_line(Loop: '||i);
dbms_output.put_line('No of students is: '||v_student);
END LOOP;
but it does not work. Please help...thanks
|
|
|
|
|
Re: CASE conditional statement [message #243095 is a reply to message #243093] |
Wed, 06 June 2007 01:13   |
kc1982
Messages: 13 Registered: October 2006
|
Junior Member |
|
|
anacedent wrote on Wed, 06 June 2007 00:58 | >but it does not work.
My car does not work.
Please tell me how to make it work.
You first with a solution.
|
I dont get your meaning.
|
|
|
|
|