For example, the data structure of mysql is as follows: query the maximum value in the three columns of ABC. Currently, there is an SQL statement that can be implemented. Would you like to ask if there are other better idea statements .. {code ...} in the afternoon, I learned another greatest function {code ...}
Example: The mysql Data structure is as follows:
Query the maximum value in column a B c. Currently, there is an SQL statement that can be implemented. Would you like to know if there are other better idea statements ..
select id,a,b,c,(a+((b+c+abs(b-c))/2)+abs(a-(b+c+abs(b-c))/2))/2 from test;
I learned another one from others in the afternoon.greatest
Function
select id,a,b,c,greatest(a,b,c) as max from XXX
Reply content:
Example: The mysql Data structure is as follows:
Query the maximum value in column a B c. Currently, there is an SQL statement that can be implemented. Would you like to know if there are other better idea statements ..
select id,a,b,c,(a+((b+c+abs(b-c))/2)+abs(a-(b+c+abs(b-c))/2))/2 from test;
I learned another one from others in the afternoon.greatest
Function
select id,a,b,c,greatest(a,b,c) as max from XXX
mysql> set @a = 5, @b = 6, @c = 11;Query OK, 0 rows affected (0.00 sec)mysql> select if(@a > @b, if(@a > @c, @a, @c), if(@b > @c, @b, @c)) max;+------+| max |+------+| 11 |+------+1 row in set (0.00 sec)
select greatest(a,b,c) max from table_name
... Can the program be processed?