0

I have this table of log finger print attendannce.

enter image description here

and i want to select the table with the result like this.

enter image description here

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.

1 Answer 1

1

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.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.