- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
DROP TABLE cur;
create table cur (
id int AUTO_INCREMENT,
name varchar(3),
value int,
data datetime,
PRIMARY KEY (id)
);
insert into cur values
(1, 'usd', 30, '20170130'),
(2, 'usd', 33, '20170130'),
(3, 'eur', 40, '20170130'),
(4, 'gbp', 50, '20170130');
select * from (select * from cur order by data DESC, id desc)
t1 group by name;
# работает только на MySQL
Lokich 01.02.2017 20:43 # +2
inkanus-gray 07.02.2017 18:42 # 0