Search
 
SCRIPT & CODE EXAMPLE
 

SQL

mysql case when or

SELECT
    CASE 
        WHEN
            column IS NULL OR another_column = 1
        THEN
            'yes' 
        ELSE
            'no' 
    END AS 'MyData'
FROM
    table_name;
Comment

mysql case

 select 
(CASE
	WHEN (market_cap < 300000000) THEN 'micro'
	WHEN (market_cap < 2000000000) THEN 'small'
	WHEN (market_cap < 10000000000) THEN 'mid'
	WHEN (market_cap < 50000000000) THEN 'large'
ELSE 'mega'
END) AS `cap_type`
from companies;
Comment

mysql case when in select

SELECT CASE col1
	WHEN 'agree' THEN 'Ok'
	WHEN 'disagree' THEN 'Ko'
    ELSE
        CASE 
            WHEN col2 >= 1 THEN 'Ko'
            ELSE 'Maybe'
        END
END AS my_result
FROM table_name;
Comment

PREVIOUS NEXT
Code Example
Sql :: mysql add columns 
Sql :: select true if exists on another table or false sqlserver 
Sql :: create table mysql integer NOT null 
Sql :: sql run multiple updates in one query 
Sql :: run function in sql 
Sql :: query to find second highest salary 
Sql :: mysql community server 
Sql :: postgres describe table 
Sql :: oracle sql sort ascending 
Sql :: delete from inner join sql 
Sql :: sql add column with default value 
Sql :: sql to array of objects 
Sql :: drop all triggers oracle 
Sql :: declare or use variable in snowflake 
Sql :: oracle sql average 
Sql :: mysql select or insert current datetime 
Sql :: dbms_metadata.get_ddl table 
Sql :: how to get specific salary in sql 
Sql :: how to check which sp is running in sql server 
Sql :: sql datum formatieren 
Sql :: generate sql from specific migration ef core 
Sql :: insert in sql 
Sql :: change column name sql 
Sql :: postgresql where and 
Sql :: not between mysql 
Sql :: Oracle filter date column by year 
Sql :: SQL Server run query on linked server 
Sql :: how to move a column to different spot mysql 
Sql :: timestamp datatype in sql 
Sql :: having in sql 
ADD CONTENT
Topic
Content
Source link
Name
9+7 =