索引控制器中的别名

I'm very sorry I ask directly.

My Database:

id | A | B | C | D

And this is my controller:

$this->db->select("*")
         ->select('A + B + C as total_X')
         ->select('total_X - D as remains_Y')
         ->from('my_table')
.........
.........
......... another codes

This is the problem:

Unknown column 'total_X' in 'field list'

I'm little bit confused how to get "remains_Y" the addition from A, B, and C as total_X and I need to get "remains_Y" from (total_X - D).

What is the right code/syntax to get the Y?

Thank you so much for the help.

Best Regards,

Kris.

Try this:

$this->db->select("*, A + B + C as total_X, A + B + C - D as remains_Y")
         ->from('my_table')