Reputation: 21
I have two different tables in sql both contaning name and marks. I want to make new table having colums names and minimum marks out of two tables for each name.
Upvotes: 0
Views: 53
Reputation: 520988
One possibility is to do a UNION
of the two tables and then query out the minimum mark for each name:
SELECT t.name, MIN(t.mark) AS min_mark
FROM
(
SELECT name, mark FROM table1
UNION ALL
SELECT name, mark FROM table2
) t
GROUP BY by t.name
Upvotes: 1