We help IT Professionals succeed at work.
Get Started

combining two case statemets

shruti27
shruti27 asked
on
259 Views
Last Modified: 2010-04-21
i have two case statements, with same set of constraints, i want to combine them to single case,  by just writing together like :
update *** set (field1, field2) = case when condition 1 then 'XXX', 'YYY'
                                                   ....
                                                   end;
this is not getting executed.
can anyone help me out here!
i have attached my actual code which i want to modify


/* first case block */
UPDATE po_ind_pending
	   SET grp =
	          CASE
	             WHEN DELAY <= 60
	                THEN '  <=60'
	             WHEN DELAY <= 90 AND DELAY > 60
	                THEN '  61-90'
	             WHEN DELAY <= 110 AND DELAY > 90
	                THEN '  91-110'
	             WHEN DELAY <= 120 AND DELAY > 110
	                THEN '  111-120'
	             WHEN DELAY <= 130 AND DELAY > 120
	                THEN '  121-130'
	             WHEN DELAY <= 140 AND DELAY > 130
	                THEN '  131-140'
	             WHEN DELAY <= 150 AND DELAY > 140
	                THEN '  141-150'
	             WHEN DELAY > 150
	                THEN '  >150'
	          END;
/* second case block */
UPDATE po_ind_pending
	   SET cat =
	          CASE
	             WHEN DELAY <= 60
	                THEN '2'
	             WHEN DELAY <= 90 AND DELAY > 60
	                THEN '3'
	             WHEN DELAY <= 110 AND DELAY > 90
	                THEN '4'
	             WHEN DELAY <= 120 AND DELAY > 110
	                THEN '5'
	             WHEN DELAY <= 130 AND DELAY > 120
	                THEN '6'
	             WHEN DELAY <= 140 AND DELAY > 130
	                THEN '7'
	             WHEN DELAY <= 150 AND DELAY > 140
	                THEN '8'
	             WHEN DELAY > 150
	                THEN '9'
	          END;

Open in new window

Comment
Watch Question
This problem has been solved!
Unlock 5 Answers and 15 Comments.
See Answers
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE