I have the following PostgreSQL table into which I insert values every hour.
currency | rate | date |
---|---|---|
EUR | 1.21 | 2012-11-2 |
JPY | 2.11 | 2012-11-2 |
GBP | 1.3 | 2012-11-2 |
CAD | 2.1 | 2012-11-2 |
EUR | 1.21 | 2012-11-2 |
JPY | 2.11 | 2012-11-2 |
GBP | 1.3 | 2012-11-2 |
CAD | 2.1 | 2012-11-2 |
EUR | 1.21 | 2012-11-3 |
JPY | 2.11 | 2012-11-3 |
GBP | 1.3 | 2012-11-3 |
CAD | 2.1 | 2012-11-3 |
EUR | 1.21 | 2012-11-4 |
JPY | 2.11 | 2012-11-4 |
GBP | 1.3 | 2012-11-4 |
CAD | 2.1 | 2012-11-4 |
Entity:
@Entity
@Table(name = "FXRATES")
public class FxRates {
@Id
@Column(name = "id", nullable = false)
private Long id;
@Column(name = "currency")
private String currency;
@Column(name = "rate")
private double rate;
@Column(name = "created_at")
private Instant createdAt;
}
As you can see I have a duplicated values into the table because date is inserted updated every day.
How I can select a table row which returns a currency for the current date?