Thanks @All.

Am using Oracle so the HAVING clause would not have worked.

I could not have the condition (C-D) in the WHERE clause since it had a GROUP function.

I tried:
SELECT * FROM (SELECT A, B, (C-D) AS E) WHERE E<0 and it worked :)

Regards
Julianne

On Tue, May 15, 2012 at 3:54 AM, Richard Gathogo <muraguri2005@gmail.com> wrote:
Hi Julianne,
HAVING should make sure on the database (SQL)  level. I am sure it works for MySQL.
Regards Richard Gathogo.
Love covers a multitude of sins.



On Tue, May 15, 2012 at 1:17 PM, Rad! <conradakunga@gmail.com> wrote:
Try WHERE C-D < 0

Not all databases (like Sybase) allow you to alias an expression and use it later as a reference


On Tuesday, May 15, 2012, julianne anyim wrote:
Hello people,

I have a query in the form;

SELECT A, B, (C-D) AS E ...

I need to return only values where E<0 for instance. I know i can achieve this in php, but is there a way i can achieve it at the SQL level?

I have tried:


SELECT A, B, (C-D) AS E
WHERE E<0

but i get an "ORA-00904: : invalid identifier" error. E is not recognized.

Any insights?

Thank you
Julianne

_______________________________________________
Skunkworks mailing list
Skunkworks@lists.my.co.ke
------------
List info, subscribe/unsubscribe
http://lists.my.co.ke/cgi-bin/mailman/listinfo/skunkworks
------------

Skunkworks Rules
http://my.co.ke/phpbb/viewtopic.php?f=24&t=94
------------
Other services @ http://my.co.ke


_______________________________________________
Skunkworks mailing list
Skunkworks@lists.my.co.ke
------------
List info, subscribe/unsubscribe
http://lists.my.co.ke/cgi-bin/mailman/listinfo/skunkworks
------------

Skunkworks Rules
http://my.co.ke/phpbb/viewtopic.php?f=24&t=94
------------
Other services @ http://my.co.ke