question

Bhupendra99 avatar image
Bhupendra99 asked

How to Avoid multiple case in sql

Hi I was assigned a task where in 6 parameter will be passed to sp and according to those para I have to define 3 slots for e.g. Para 1 = 20 , Para 2 = 40, Para -3 = 60 , Para-1Sign = >,Para-2Sign = >, Para-3Sign = > so the out put should be like Min Max 0 20 21 40 41 60 since all the ParaSign paraneter contains same comparision operator > it is fine but it can have any value that is first might contain > second contains < third contains >= values allowed are (<,>,=,>=,]]]]]]]' THEN @Slot1+1 WHEN @Slot1Sign= '>=' THEN @Slot1 END, CASE WHEN @Slot1Sign = '' THEN @Slot2 ELSE @Slot2-1 END INSERT INTO #EscCategoryTimings SELECT @EscCatMastID,CASE WHEN @Slot2Sign = '' THEN @Slot2+1 WHEN @Slot2Sign= '>=' THEN @Slot2 END, CASE WHEN @Slot2Sign = '' THEN @Slot3 ELSE @Slot3-1 END FROM #EscCategoryTimings INSERT INTO #EscCategoryTimings SELECT @EscCatMastID,CASE WHEN @Slot3Sign = '' THEN @Slot3+1 WHEN @Slot3Sign= '>=' THEN @Slot3 END, CASE WHEN @Slot3Sign IN ('=',']]] case-statement
case-statement.sql (1.6 KiB)
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

0 Answers

·

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.