Unix Technical Forum

How can I do something like this "SELECT MAX(col1, col2, col3) FROM mytable ORDER BY MAX(col1, col2, col3);" ?

This is a discussion on How can I do something like this "SELECT MAX(col1, col2, col3) FROM mytable ORDER BY MAX(col1, col2, col3);" ? within the MySQL General forum forums, part of the MySQL category; --> Hi, I would like do something like : SELECT MAX(col1, col2, col3) FROM mytable ORDER BY MAX(col1, col2, col3); ...


Go Back   Unix Technical Forum > Database Server Software > MySQL > MySQL General forum

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 02-28-2008, 06:37 AM
=?ISO-8859-1?Q?KLEIN_St=E9phane?=
 
Posts: n/a
Default How can I do something like this "SELECT MAX(col1, col2, col3) FROM mytable ORDER BY MAX(col1, col2, col3);" ?

Hi,

I would like do something like :

SELECT MAX(col1, col2, col3) FROM mytable ORDER BY MAX(col1, col2, col3);

I know this syntax is wrong but I would like get a solution to this stuff.

Thanks for your help.
Stephane
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 02-28-2008, 06:37 AM
Ricardas S
 
Posts: n/a
Default Re: How can I do something like this "SELECT MAX(col1, col2, col3) FROM mytable ORDER BY MAX(col1, col2, col3);" ?

Have you tried
MAX((col1*(MAX_VALUE_OF_COL1+1)+col2)*(MAX_VALUE_O F_COL2+1)+col3)

----- Original Message -----
From: "KLEIN Stéphane" <klein.stephane@gmail.com>
To: <mysql@lists.mysql.com>
Sent: Wednesday, June 13, 2007 09:30
Subject: How can I do something like this "SELECT MAX(col1, col2, col3) FROM mytable ORDER BY MAX(col1, col2, col3);" ?


> Hi,
>
> I would like do something like :
>
> SELECT MAX(col1, col2, col3) FROM mytable ORDER BY MAX(col1, col2, col3);
>
> I know this syntax is wrong but I would like get a solution to this stuff.
>
> Thanks for your help.
> Stephane
>
> --
> MySQL General Mailing List
> For list archives: http://lists.mysql.com/mysql
> To unsubscribe: http://lists.mysql.com/mysql?unsub=rs@nfq.lt
>


Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 02-28-2008, 06:37 AM
Ricardas S
 
Posts: n/a
Default Re: How can I do something like this "SELECT MAX(col1, col2, col3) FROM mytable ORDER BY MAX(col1, col2, col3);" ?

Ops, small mistake, shoud be

MAX((col1*(MAX_VALUE_OF_COL2+1)+col2)*(MAX_VALUE_O F_COL3+1)+col3)


----- Original Message -----
From: "Ricardas S" <ricardas@nfq.lt>
To: <mysql@lists.mysql.com>
Sent: Wednesday, June 13, 2007 09:36
Subject: Re: How can I do something like this "SELECT MAX(col1, col2, col3) FROM mytable ORDER BY MAX(col1, col2, col3);" ?


> Have you tried
> MAX((col1*(MAX_VALUE_OF_COL1+1)+col2)*(MAX_VALUE_O F_COL2+1)+col3)
>
> ----- Original Message -----
> From: "KLEIN Stéphane" <klein.stephane@gmail.com>
> To: <mysql@lists.mysql.com>
> Sent: Wednesday, June 13, 2007 09:30
> Subject: How can I do something like this "SELECT MAX(col1, col2, col3) FROM mytable ORDER BY MAX(col1, col2, col3);" ?
>
>
>> Hi,
>>
>> I would like do something like :
>>
>> SELECT MAX(col1, col2, col3) FROM mytable ORDER BY MAX(col1, col2, col3);
>>
>> I know this syntax is wrong but I would like get a solution to this stuff.
>>
>> Thanks for your help.
>> Stephane
>>
>> --
>> MySQL General Mailing List
>> For list archives: http://lists.mysql.com/mysql
>> To unsubscribe: http://lists.mysql.com/mysql?unsub=rs@nfq.lt
>>

>
>
> --
> MySQL General Mailing List
> For list archives: http://lists.mysql.com/mysql
> To unsubscribe: http://lists.mysql.com/mysql?unsub=rs@nfq.lt
>


Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 02-28-2008, 06:37 AM
=?ISO-8859-1?Q?KLEIN_St=E9phane?=
 
Posts: n/a
Default Re: How can I do something like this "SELECT MAX(col1, col2, col3) FROM mytable ORDER BY MAX(col1, col2, col3);" ?

2007/6/13, Ricardas S <ricardas@nfq.lt>:
> Ops, small mistake, shoud be
>
> MAX((col1*(MAX_VALUE_OF_COL2+1)+col2)*(MAX_VALUE_O F_COL3+1)+col3)
>


Sorry, my question is ashamed.

Example, I've this row :

Col1 | Col2 | Col3
1 | 5 | 8
6 | 2 | 4
12 | 13 | 6

After my query, I would like this :

Max_value_col
6
8
13

Well, I would like MAX value of cols of one row, not on all the column.

I don't know if my explication it more clear.

Stephane
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #5 (permalink)  
Old 02-28-2008, 06:37 AM
Ricardas S
 
Posts: n/a
Default Re: How can I do something like this "SELECT MAX(col1, col2, col3) FROM mytable ORDER BY MAX(col1, col2, col3);" ?

select greatest(col1,col2,col3) from
(select max(col1) as col1 from t) a,
(select max(col2) as col2 from t) b,
(select max(col3) as col3 from t) c

----- Original Message -----
From: "KLEIN Stéphane" <klein.stephane@gmail.com>
To: "Ricardas S" <ricardas@nfq.lt>
Cc: <mysql@lists.mysql.com>
Sent: Wednesday, June 13, 2007 10:00
Subject: Re: How can I do something like this "SELECT MAX(col1, col2, col3) FROM mytable ORDER BY MAX(col1, col2, col3);" ?


> 2007/6/13, Ricardas S <ricardas@nfq.lt>:
>> Ops, small mistake, shoud be
>>
>> MAX((col1*(MAX_VALUE_OF_COL2+1)+col2)*(MAX_VALUE_O F_COL3+1)+col3)
>>

>
> Sorry, my question is ashamed.
>
> Example, I've this row :
>
> Col1 | Col2 | Col3
> 1 | 5 | 8
> 6 | 2 | 4
> 12 | 13 | 6
>
> After my query, I would like this :
>
> Max_value_col
> 6
> 8
> 13
>
> Well, I would like MAX value of cols of one row, not on all the column.
>
> I don't know if my explication it more clear.
>
> Stephane
>
> --
> MySQL General Mailing List
> For list archives: http://lists.mysql.com/mysql
> To unsubscribe: http://lists.mysql.com/mysql?unsub=rs@nfq.lt
>


Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #6 (permalink)  
Old 02-28-2008, 06:37 AM
Ricardas S
 
Posts: n/a
Default Re: How can I do something like this "SELECT MAX(col1, col2, col3) FROM mytable ORDER BY MAX(col1, col2, col3);" ?

ops again you probably needed just
select greatest(col1,col2,col3) from t order by 1

----- Original Message -----
From: "Ricardas S" <ricardas@nfq.lt>
To: "KLEIN Stéphane" <klein.stephane@gmail.com>
Cc: <mysql@lists.mysql.com>
Sent: Wednesday, June 13, 2007 11:02
Subject: Re: How can I do something like this "SELECT MAX(col1, col2, col3) FROM mytable ORDER BY MAX(col1, col2, col3);" ?


> select greatest(col1,col2,col3) from
> (select max(col1) as col1 from t) a,
> (select max(col2) as col2 from t) b,
> (select max(col3) as col3 from t) c
>
> ----- Original Message -----
> From: "KLEIN Stéphane" <klein.stephane@gmail.com>
> To: "Ricardas S" <ricardas@nfq.lt>
> Cc: <mysql@lists.mysql.com>
> Sent: Wednesday, June 13, 2007 10:00
> Subject: Re: How can I do something like this "SELECT MAX(col1, col2, col3) FROM mytable ORDER BY MAX(col1, col2, col3);" ?
>
>
>> 2007/6/13, Ricardas S <ricardas@nfq.lt>:
>>> Ops, small mistake, shoud be
>>>
>>> MAX((col1*(MAX_VALUE_OF_COL2+1)+col2)*(MAX_VALUE_O F_COL3+1)+col3)
>>>

>>
>> Sorry, my question is ashamed.
>>
>> Example, I've this row :
>>
>> Col1 | Col2 | Col3
>> 1 | 5 | 8
>> 6 | 2 | 4
>> 12 | 13 | 6
>>
>> After my query, I would like this :
>>
>> Max_value_col
>> 6
>> 8
>> 13
>>
>> Well, I would like MAX value of cols of one row, not on all the column.
>>
>> I don't know if my explication it more clear.
>>
>> Stephane
>>
>> --
>> MySQL General Mailing List
>> For list archives: http://lists.mysql.com/mysql
>> To unsubscribe: http://lists.mysql.com/mysql?unsub=rs@nfq.lt
>>

>
>
> --
> MySQL General Mailing List
> For list archives: http://lists.mysql.com/mysql
> To unsubscribe: http://lists.mysql.com/mysql?unsub=rs@nfq.lt
>


Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #7 (permalink)  
Old 02-28-2008, 06:37 AM
=?ISO-8859-1?Q?KLEIN_St=E9phane?=
 
Posts: n/a
Default Re: How can I do something like this "SELECT MAX(col1, col2, col3) FROM mytable ORDER BY MAX(col1, col2, col3);" ?

2007/6/13, Ricardas S <ricardas@nfq.lt>:
> ops again you probably needed just
> select greatest(col1,col2,col3) from t order by 1


Thanks, it's work very well.

best regards
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 02:35 AM.


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