Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- CREATE TABLE tabel(
- kode_brg INT,
- tgl_stock DATETIME
- );
- INSERT INTO tabel VALUES
- (1,'2017-01-22 23:55:57'),
- (1,'2017-01-22 23:44:07'),
- (2,'2017-01-22 21:10:24'),
- (1,'2017-01-22 19:52:57');
- SELECT * FROM tabel;
- +----------+---------------------+
- | kode_brg | tgl_stock |
- +----------+---------------------+
- | 1 | 2017-01-22 23:55:57 |
- | 1 | 2017-01-22 23:44:07 |
- | 2 | 2017-01-22 21:10:24 |
- | 1 | 2017-01-22 19:52:57 |
- +----------+---------------------+
- 4 rows in set (0.00 sec)
- SELECT kode_brg,MAX(tgl_stock) AS tgl_stock
- FROM tabel
- GROUP BY kode_brg;
- +----------+---------------------+
- | kode_brg | tgl_stock |
- +----------+---------------------+
- | 1 | 2017-01-22 23:55:57 |
- | 2 | 2017-01-22 21:10:24 |
- +----------+---------------------+
- 2 rows in set (0.00 sec)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement