Software QA (13)
SQL Server (1)
How To Use CASE Expression
How To Use CASE Expression? - MySQL FAQs - Introduction to SQL Basics
There are 2 ways to use the CASE expression. The first way is to return one of the predefined values based on the comparison of a given value to a list of target values. The second way is to return one of the predefined values based on a list of conditions. Here is the syntax of both types of CASE expressions:
CASE value WHEN target_value THEN result WHEN target_value THEN result WHEN target_value THEN result ... ELSE result END CASE WHEN condition THEN result WHEN condition THEN result WHEN condition THEN result ... ELSE result END
The tutorial exercise below gives two good examples:
SELECT CASE 'Sun' WHEN 'Mon' THEN 'Open' WHEN "Fri" THEN "Open" ELSE 'Closed' END FROM DUAL; Closed SELECT CASE WHEN HOUR(CURRENT_TIME())<9 THEN 'Closed' WHEN HOUR(CURRENT_TIME())>17 THEN 'Closed' ELSE 'Open' END FROM DUAL; Closed
2007-05-11, 4618👍, 0💬
What is the difference between strings and character arrays? A major difference is: string will have...
How to measure functional software requirement specification (SRS) documents? Well, we need to defin...
How do you open an SSH connection to a remote box? ????
Who Developed HTML? HTML was originally developed by Tim Berners-Lee while at CERN, and popularized ...
If client side validation is enabled in your Web page, does that mean server side code is not run? W...