Search
 
SCRIPT & CODE EXAMPLE
 

SQL

select if then postgresql

SELECT field1, field2,
  CASE
    WHEN field1>0 THEN field2/field1
    ELSE 0
  END 
  AS field3
FROM test
Comment

postgress if

-- use postgress case

SELECT name, continent, indep_year,
    CASE WHEN indep_year < 1900 THEN 'before 1900'
         WHEN indep_year <= 1930 THEN 'between 1900 and 1930'
         ELSE 'after 1930' END
         AS indep_year_group
FROM countries
ORDER BY indep_year_group;
Comment

PREVIOUS NEXT
Code Example
Sql :: Mysql table variables 
Sql :: mysqldump 1 table only 
Sql :: export database sql file from xampp using cmd 
Sql :: date in mysql 
Sql :: mysql size of database 
Sql :: what is cursor in sql server with example 
Sql :: double in sql server example 
Sql :: declare date variable sql 
Sql :: microsoft sql server python connection 
Sql :: group_concat mysql 
Sql :: min mysql 
Sql :: SQL FETCH FIRST Clause 
Sql :: get size of mysql database 
Sql :: create-table 
Sql :: mysql workbench format date 
Sql :: back up stored procedures mysql 
Sql :: last 2 mins sql server 
Sql :: get last record deluge 
Sql :: show database not empty tables postgres 
Sql :: sql server fn_dblog 
Sql :: sql server size of every table in a db 
Sql :: Write an SQL query to fetch the count of employees working in the department ‘Admin’. 
Sql :: sql recursive query 
Sql :: greater than or equal to symbol in postgres 
Sql :: how to completely uninstall sql server 
Sql :: sqlalchemy default value for column 
Sql :: update sql 
Sql :: Order of execution SQL or MySql query Or Logical order of operations: 
Sql :: php select data from mysql database without column name 
Sql :: sql cross apply vs join 
ADD CONTENT
Topic
Content
Source link
Name
1+3 =