Hi,
I need help with a query. I got two tables that looks like this:
table1
..id..|..sum..|..who..|..item..|
...0..|..100..|....2.....|......1...|
...1..|..150..|....3.....|......1...|
...2..|..200..|....3.....|......2...|
table2
..id..|..name..|
...1..|..site1...|
...2..|..site2...|
The item value in table1 reffers to the id of table2.
I need a query that gets the fields where a user (who) got the biggest sum and the name from table 2. I tryed to left join the with this query.
SELECT max(a.sum), b.name FROM table1 AS a LEFT JOIN table2 AS b ON a.item = b.id WHERE a.who = '1' GROUP BY a.item
The problem with that query is that is gets the bigges sum of that user... and I only need the info if the user got the bigges sum on any items!
I have been trying for a day now... but without any luck!
Need help 🙂