1
incompatible 2014-11-21 10:31:54 +08:00 1
select name, max(dateline) from t group by name
|
2
vook OP @incompatible 各个 name 的最新的 dateline 所在记录, 还包括 id 等其他的字段。
|
3
xlmo 2014-11-21 10:37:28 +08:00 1
SELECT * FROM table GROUP BY `name` ORDER BY dateline DESC
|
4
yanleijava 2014-11-21 10:52:27 +08:00 1
你指的是Group By排序,参考 http://iyanlei.com/hive_groupby_order.html
|
5
staticor 2014-11-21 10:55:30 +08:00 1
@vook selct * from
(select name, max(dateline) as maxdate from t group by name) natura left join ( select name, dateline as maxdateline , id ... from t ) ?这样试试 |
7
vook OP @yanleijava
SELECT * FROM (SELECT * FROM t1 ORDER BY dateline DESC) as t2 GROUP BY `name`; 就是这个。谢谢! 学习了! |
8
laoyuan 2014-11-21 12:41:01 +08:00
嗯,只能这样我也是这么写的
|
9
laoyuan 2014-11-21 12:41:34 +08:00
不过后来我觉得分两条写也无所谓
|
10
alsotang 2014-11-21 13:34:21 +08:00 1
呃,楼上全是乱来。你们就不懂有个叫 window function 的东西存在 sql 中吗
|
11
Fedor 2014-11-21 22:22:54 +08:00
SELECT group_concat(id order by dateline desc SEPARATOR '') AS id FROM table group by game_id;
|