Unix Technical Forum

Non-aggregating max()?

This is a discussion on Non-aggregating max()? within the MySQL forums, part of the Database Server Software category; --> Hi, since MAX() is an aggregate function, is there a "normal" MAX() that works like this: SELECT MAX(1,2); -> ...


Go Back   Unix Technical Forum > Database Server Software > MySQL

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 02-28-2008, 11:24 AM
=?iso-8859-1?B?QW5kcukgSORuc2Vs?=
 
Posts: n/a
Default Non-aggregating max()?

Hi,

since MAX() is an aggregate function, is there a "normal" MAX() that
works like this:

SELECT MAX(1,2);
-> 2

Regards,
André

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 02-28-2008, 11:24 AM
Pavel Lepin
 
Posts: n/a
Default Re: Non-aggregating max()?


André Hänsel <andre@webkr.de> wrote in
<1186627664.860237.165850@w3g2000hsg.googlegroups. com>:
> since MAX() is an aggregate function, is there a "normal"
> MAX() that works like this:
>
> SELECT MAX(1,2);
> -> 2


mysql> SET @a=1;
Query OK, 0 rows affected (0.06 sec)

mysql> SET @b=2;
Query OK, 0 rows affected (0.00 sec)

mysql> SELECT IF(@a>@b,@a,@b);
+-----------------+
| IF(@a>@b,@a,@b) |
+-----------------+
| 2 |
+-----------------+
1 row in set (0.04 sec)

mysql> SELECT IF(@b>@a,@b,@a);
+-----------------+
| IF(@b>@a,@b,@a) |
+-----------------+
| 2 |
+-----------------+
1 row in set (0.00 sec)

Beware of NULLs.

--
....the pleasure of obedience is pretty thin compared with
the pleasure of hearing a rotten tomato hit someone in the
rear end. -- Garrison Keillor
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT. The time now is 05:11 PM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.2.0
www.UnixAdminTalk.com