Skip to content
Advertisement

Tag: min

Find sum of hours for each date worked

I have a table of timesheet entries set up like this: id job_id employee_id hours_worked date_worked 1 1 111 8 2022-10-01 2 1 222 8 2022-10-01 3 1 222 8 2022-10-02 4 2 222 8 2022-10-03 5 2 111 8 2022-10-04 6 2 222 5 2022-10-05 7 3 111 8 2022-10-04 8 4 333 8 2022-10-07 9 4 111 3

How to use min() together with other column in SQL

I am building an application consisting of an SQL backend and several microservices that communicate with this backend. I am trying to get as little data as possible from the database over the wire so I am trying to fetch the exact records so I don’t have to start looping in the application logic. So this is the source table

Take oldest record in a set of rows

So, I have this problem, I have this set of records in a table TemperatureID CastingID TemperatureDateTime TemperatureValue 1421294 1073513 2021-01-07 11:53:00.000 1648 1421295 1073513 2021-01-07 11:54:00.000 1698 1421326 1073514 2021-01-07 22:00:00.000 1594 1421327 1073514 2021-01-07 22:11:00.000 1609 and this repeated many times. My problem is that I have to take only the oldest record for each set of CastingID

How to compare multiple rows

I have a table with data like following, want to return those group_id with unique data. Both group_id 3 and 4 have two component 123 and 456, so they are “duplicated”, we just need to return the smaller group_id, that’s 3. Also group_id 5 doesn’t have a duplication, it can be returned. So we want group_id 3 and 5 to

Finding daily registered users

I have a table which includes the information of player_id, first_timestamp, last_timestamp, and date, etc. So I have initially 10 payers on 2020-07-08, and then 18 players on 2020-07-09, some of the players from previous day might appear on 2020-07-09 again. And I’m trying to find the new players registered on 2020-07-09 that did not appear on 2020-07-08, but I

Advertisement