
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

try HAVING instead of WHERE (iirc) On Tue, May 15, 2012 at 1:12 PM, julianne anyim <julianneanyim@gmail.com> 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
-- Best Regards, Christian Ledermann <*)))>{ If you save the living environment, the biodiversity that we have left, you will also automatically save the physical environment, too. But If you only save the physical environment, you will ultimately lose both. 1) Don’t drive species to extinction 2) Don’t destroy a habitat that species rely on. 3) Don’t change the climate in ways that will result in the above. }<(((*>

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

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

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
participants (4)
-
Christian Ledermann
-
julianne anyim
-
Rad!
-
Richard Gathogo