Example Records :
|name |price |source|lastest_update|
|name A| 20.00|att |04/10/2019 00:00:00|
|name A| 30.00|att |04/11/2019 02:00:00|
|name A| 50.00|sprint|04/10/2019 01:00:00|
|name A| 40.00|sprint|04/11/2019 21:00:00|
Basically if we're using group by "group by name" the price that we'll get is the first one of the records, it's $20, but i want to get the max price based on lastest_update (date). So the results will be :
|name |att_price|sprint_price|
|name A| 30.00 | 40.00 |
My query
SELECT
MAX(WHEN source = 'att' THEN price ELSE 0 END) as att_price,
MAX(WHEN source = 'sprint' THEN price ELSE 0 END) as sprint_price
FROM table GROUP BY name;
Thank you very much.