mysql - SQL sort data based on different columns -
i need sql problem. i'm not sure it's possible do, have table:
obtained sql statement:
select distinct account.box, account.name, account.currency, account.lastupdated, account.lastupdatedby, transactions.totals account left join transactions on account.accountguid = transactions.accountguid
so comparing totals each groups of name or currency, obtain highest totals each group. (null values replaced zeroes).
you seem want group by
:
select a.box, a.name, a.currency, a.lastupdated, a.lastupdatedby, max(t.totals) totals account left join transactions t on a.accountguid = t.accountguid group a.box, a.name, a.currency, a.lastupdated, a.lastupdatedby;
note: added table aliases make query easier understand.
Comments
Post a Comment