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 :: enable sql server full text indexing 
Sql :: sql server locks 
Sql :: create new schema mysql 
Sql :: create a view in sqlite 
Sql :: savepoint in sql 
Sql :: drop table if exists test 
Sql :: mysql cdn link 
Sql :: phpmyadmin password root 
Sql :: create_engine sqlalchemy with parsed url sql server 
Sql :: oracle timestamp to date 
Sql :: mysql select update same table 
Sql :: java string to sql timestamp 
Sql :: sql case 
Sql :: oracle pagination query offset 
Sql :: sql server select first day of previous year 
Sql :: zsh-syntax-highlighting zsh-autosuggestions 
Sql :: sql select most frequent value in column 
Sql :: mysql backup table 
Sql :: sql find duplicate records in two tables 
Sql :: sql server alter table add column tinyint 
Sql :: add a day big query 
Sql :: sql query to select records entered in last 24 hours 
Sql :: sql counter column 
Sql :: sum sqlalchemy 
Sql :: oracle drop job if exists 
Sql :: postgresql not case sensitive where in 
Sql :: alter column set not null to null postgres 
Sql :: MySQL get all previous date record 
Sql :: SQL Modify Column in a Table -PostgreSQL 
Sql :: flask marshmallow sqlalchemy 
ADD CONTENT
Topic
Content
Source link
Name
6+9 =