How do I do multiple CASE WHEN conditions using SQL Server 2008?

前端 未结 10 2008
被撕碎了的回忆
被撕碎了的回忆 2020-11-27 09:57

What I\'m trying to do is use more than one CASE WHEN condition for the same column.

Here is my code for the query:

   SELECT   Url=\'\',
                    


        
10条回答
  •  谎友^
    谎友^ (楼主)
    2020-11-27 10:27

    You can use below example of case when with multiple conditions.

    SELECT
      id,stud_name,
      CASE
        WHEN marks <= 40 THEN 'Bad'
        WHEN (marks >= 40 AND
          marks <= 100) THEN 'good'
        ELSE 'best'
      END AS Grade
    FROM Result
    

提交回复
热议问题