i'm using oracle sql developer. i have two tables
transactions:
╔════╤═══════╗
║ id │ value ║
╠════╪═══════╣
║ 1 │ 10 ║
╟────┼───────╢
║ 1 │ 20 ║
╟────┼───────╢
║ 2 │ 30 ║
╟────┼───────╢
║ 3 │ 40 ║
╚════╧═══════╝
and users:
╔════╤═════════╤═════╗
║ id │ country │ sex ║
╠════╪═════════╪═════╣
║ 1 │ Germany │ m ║
╟────┼─────────┼─────╢
║ 2 │ Germany │ f ║
╟────┼─────────┼─────╢
║ 3 │ France │ m ║
╚════╧═════════╧═════╝
i want to get max value for each country like this
╔════╤═════════╤═════╤══════════╗
║ id │ country │ sex │ maxvalue ║
╠════╪═════════╪═════╪══════════╣
║ 2 │ Germany │ f │ 30 ║
╟────┼─────────┼─────┼──────────╢
║ 3 │ France │ m │ 40 ║
╚════╧═════════╧═════╧══════════╝
i know how to get max value for each user and join tables
SELECT u.*, max
FROM users u
LEFT JOIN
(SELECT id, max(value) as max
FROM transactions
group by ID) t
on u.id = t.id;
what should i change to get a max value for each country?