Reputation: 33
I have this table of log finger print attendannce.
and i want to select the table with the result like this.
as you can see, in the mindailylog field, it contains the minumum date of that day, and the maxdailylog field value contains the max value of that day.
Upvotes: 0
Views: 1087
Reputation: 1269773
You can use window functions:
select t.*,
min(waktuabsen) over (partition by userid, waktuabsen::date),
max(waktuabsen) over (partition by userid, waktuabsen::date),
from t;
This does the minimum per user_id
. If you want the overall minimum, just remove userid
from the partition by
.
Upvotes: 1