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); ...
| |||||||
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| ||||
| 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 |
| |||
| 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 > |
| |||
| 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 > |
| |||
| 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 |
| |||
| 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 > |
| |||
| 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 > |
| ||||
| 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 |