Search
 
SCRIPT & CODE EXAMPLE
 

SQL

oracle case

SELECT product_id, product_type_id,
  CASE product_type_id
    WHEN 1 THEN 'Book'
    WHEN 2 THEN 'Video'
    WHEN 3 THEN 'DVD'
    WHEN 4 THEN 'CD'
    ELSE 'Magazine'
  END
FROM products;
Comment

select case when oracle

SELECT
	CASE COLUMN1 WHEN 'N' THEN
		CASE COLUMN2
			WHEN 1 THEN NVL(COLUMN3,COLUMN4)
			WHEN 2 THEN NVL(COLUMN3,COLUMN4) 
			WHEN 3 THEN NVL(COLUMN3,COLUMN4) 
			WHEN 4 THEN NVL(COLUMN3,COLUMN4) 
			WHEN 5 THEN NVL(COLUMN3,COLUMN4) 
			WHEN 6 THEN NVL(COLUMN3,COLUMN4)
		ELSE COLUMN5 END 
	ELSE COLUMN6 END
FROM TABLE_NAME
Comment

PREVIOUS NEXT
Code Example
Sql :: psql get last rows 
Sql :: android sqlite database example 
Sql :: sql select all records from all tables where not empty 
Sql :: mysql changer nom table 
Sql :: postgres create multiple index 
Sql :: how to connect to postgres 
Sql :: mysql disable triggers 
Sql :: how to define a save method in ruby for sql databases 
Sql :: postgres extract date from timestamp 
Sql :: how to casting data types in postgresql 
Sql :: sql inner join 
Sql :: sql create table 
Sql :: postgresql create table as select 
Sql :: sql insert values into table 
Sql :: sum sqlserver 
Sql :: sql distinct clause 
Sql :: mysql keyword search 
Sql :: relation does not exist postgresql 
Sql :: sqrt(i) 
Sql :: python get backup of sql 
Sql :: delete from select postgresql 
Sql :: mysql max() 
Sql :: date less than in sql 
Sql :: select indexes postgres 
Sql :: get month sql 
Sql :: mysql string split to array 
Sql :: vi set sql syntax 
Sql :: sql foreign key constraint 
Sql :: oracle list partitioned tables 
Sql :: remove decimal in sql server 
ADD CONTENT
Topic
Content
Source link
Name
3+3 =