Re: Comparing an alias ...

2001-12-01 Thread Carl Troein


Julio Faerman writes:

 Hi ... I am need the following query to work :
 SELECT
 min(my_colum) as MINIMAL_VALUE
 WHERE
 MINIMAL_VALUE  10
 
 The query is not EXACTLY as this one, but i think it is enough to get you
 the idea of my problem...

What would this mean? The WHERE clause is what determines what rows
will be used in the GROUP BY functions, e.g. MIN(). How do you know
what rows to use when you need to know what rows to use before you
can figure out the criteria for what rows to use?
Trying to express in words what you wish to accomplish, I'd say that
you want the smallest of all my_column such that this value is greater
than ten. This would be equivalent to WHERE my_column  10, but if
that's what you want I suppose you wouldn't be asking.

Someone suggested HAVING, but as far as I can see using HAVING to
accomplish MIN(column)constant is equivalent to WHERE columnconstant.

//C - not wearing his glasses

-- 
 Carl Troein - Círdan / Istari-PixelMagic - UIN 16353280
 [EMAIL PROTECTED] | http://pixelmagic.dyndns.org/~cirdan/
 Amiga user since '89, and damned proud of it too.


-
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/   (the list archive)

To request this thread, e-mail [EMAIL PROTECTED]
To unsubscribe, e-mail [EMAIL PROTECTED]
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php




Re: Comparing an alias ...

2001-12-01 Thread Julio Faerman

HAVING worked OK thus .
-
 What would this mean? The WHERE clause is what determines what rows
 will be used in the GROUP BY functions, e.g. MIN(). How do you know
 what rows to use when you need to know what rows to use before you
 can figure out the criteria for what rows to use?
 Trying to express in words what you wish to accomplish, I'd say that
 you want the smallest of all my_column such that this value is greater
 than ten. This would be equivalent to WHERE my_column  10, but if
 that's what you want I suppose you wouldn't be asking.

 Someone suggested HAVING, but as far as I can see using HAVING to
 accomplish MIN(column)constant is equivalent to WHERE columnconstant.

 //C - not wearing his glasses

 --
  Carl Troein - Círdan / Istari-PixelMagic - UIN 16353280
  [EMAIL PROTECTED] | http://pixelmagic.dyndns.org/~cirdan/
  Amiga user since '89, and damned proud of it too.


 -
 Before posting, please check:
http://www.mysql.com/manual.php   (the manual)
http://lists.mysql.com/   (the list archive)

 To request this thread, e-mail [EMAIL PROTECTED]
 To unsubscribe, e-mail
[EMAIL PROTECTED]
 Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php



-
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/   (the list archive)

To request this thread, e-mail [EMAIL PROTECTED]
To unsubscribe, e-mail [EMAIL PROTECTED]
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php




Comparing an alias ...

2001-11-30 Thread Julio Faerman

Hi ... I am need the following query to work :
SELECT
min(my_colum) as MINIMAL_VALUE
WHERE
MINIMAL_VALUE  10

The query is not EXACTLY as this one, but i think it is enough to get you
the idea of my problem...

Thnx for any  help !
[]~S
julio


-
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/   (the list archive)

To request this thread, e-mail [EMAIL PROTECTED]
To unsubscribe, e-mail [EMAIL PROTECTED]
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php




Re: Comparing an alias ...

2001-11-30 Thread sherzodR


Try to use HAVING instead of WHERE. I hope that will help.





Julio Faerman wrote:

JF: Hi ... I am need the following query to work :
JF: SELECT
JF: min(my_colum) as MINIMAL_VALUE
JF: WHERE
JF: MINIMAL_VALUE  10
JF:
JF: The query is not EXACTLY as this one, but i think it is enough to get you
JF: the idea of my problem...
JF:
JF: Thnx for any  help !
JF: []~S
JF: julio
JF:
JF:
JF: -
JF: Before posting, please check:
JF:http://www.mysql.com/manual.php   (the manual)
JF:http://lists.mysql.com/   (the list archive)
JF:
JF: To request this thread, e-mail [EMAIL PROTECTED]
JF: To unsubscribe, e-mail 
[EMAIL PROTECTED]
JF: Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php
JF:

-- 
sherzodR [EMAIL PROTECTED]
use CGI::Session;


-
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/   (the list archive)

To request this thread, e-mail [EMAIL PROTECTED]
To unsubscribe, e-mail [EMAIL PROTECTED]
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php




Comparing an alias ...

2001-11-30 Thread Giuseppe Maxia

It won't work this way.

SELECT min(my_column) as MINIMAL_VALUE 

will give you ONE record only. Therefore, an additional condition (which 
you can get with HAVING, not WHERE) will be meaningless.

e.g:
SELECT min(my_column) as MINIMAL_VALUE 
FROM mytable
HAVING MINIMAL_VALUE  10

will return an empty set if the minimal value is = 10.


This one, will give you some more:

SELECT other_column, min(my_column) as MINIMAL_VALUE 
FROM mytable
GROUP BY other_column
HAVING MINIMAL_VALUE  10

Here you will get one line for each distinct value of other_column,
provided that the minimimum value is bigger than 10.

Bye
Giuseppe Maxia



Hi ... I am need the following query to work :
SELECT
min(my_colum) as MINIMAL_VALUE
WHERE
MINIMAL_VALUE  10

The query is not EXACTLY as this one, but i think it is enough to get you
the idea of my problem...

Thnx for any  help !
[]~S
julio




-
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/   (the list archive)

To request this thread, e-mail [EMAIL PROTECTED]
To unsubscribe, e-mail [EMAIL PROTECTED]
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php