我有了数据的表,看起来是这样的:在单个SQL语句中选择最近的多个值
data_type, value, datetime
World of Warcraft, 500, 2012-12-02
Quake 3, 1500, 2013-12-02
Quake 3, 1400, 2013-02-04
World of Warcraft, 1200, 2013-05-20
Final Fantasy, 100, 2013-02-03
Final Fantasy, 500, 2013-03-05
我想选择是像下面这样:
data_type, value World of Warcraft, 1200 Quake 3, 1500 Final Fantasy, 500
select
most recent value for 'World of Warcraft',
most recent value for 'Quake 3',
most recent value for 'Final Fantasy'
所以我在单个语句中获得了每个元素的最新值,而不必将它们分开。我会如何去做这件事?
[使用单个SQL语句选择多个Max()值的可能的重复-postgresql](http://stackoverflow.com/questions/18494829/selecting-multiple-max-values-using-a-single-sql -statement-postgresql) –
我没有,这个问是关于选择最近的地方,因为另一个是要求最大值http://stackoverflow.com/questions/18494829/selecting-multiple-max-values-using -a-single-sql-statement-postgresql 如果您阅读了评论,那么帮助的人就是真正提出新问题的人。但感谢您的帮助.... – user2146933
@a_horse_with_no_name这实际上是一个不同的问题 – Lamak