Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

I have two tables where the column names of table B gets stored as values in table A. I need to fetch max value of columns from table B. Could you please help in acheiving this..

table A structure as follows

| id | name |

| 1 | ABC |

| 2 | XYZ |

table B has column names as 'ABC' and 'XYZ'. I'm stuck to fetch max of columns ABC and XYZ from table B. Any help would be of highly appreciated.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
251 views
Welcome To Ask or Share your Answers For Others

1 Answer

Maybe you could, first, union both tables, and then calculate the maximum values. like:

SELECT max(ABC), max(XYZ) FROM( select * from table_a UNION ALL select * from table_b ) table;


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...