Question: i have 

```
SELECT col, col1 from table
CASE
WHEN other_col = 'Canada' THEN  1
    ELSE 2
END AS col2

```

it works fine, but i want to calculate 

`col3` based on value from `col2`

it should be simple `col3` = value from `col2 / 2`
and return it in the same `select`

How to achieve it?

Answer: 
You can't use the column `col2` in an expression like `col2 / 2` inside the same select statement.   

You can repeat the same CASE statement like this:

```
SELECT 
  col, 
  col1, 
  CASE WHEN other_col = 'Canada' THEN 1 ELSE 2 END AS col2
  CASE WHEN other_col  = 'Canada' THEN 0.5 ELSE 1 END AS col3
FROM table

```

or by nesting the SELECT statement inside another:

```
SELECT
  t.*,
  t.col2 / 2 AS col3
FROM (
  SELECT 
    col, 
    col1, 
    CASE WHEN other_col = 'Canada' THEN 1 ELSE 2 END AS col2
  FROM table 
) AS t

```
You can use a lateral join in Postgres:

```
SELECT t.col, t.col1, v.col2
FROM table t CROSS JOIN LATERAL
     (VALUES (CASE WHEN other_col = 'Canada' THEN  1 ELSE 2 END)
     ) v(col2);

```

You can then use `v.col2` to your heart's delight in any other expression you want to.