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
Tag: min
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
How to select max and min of 1 column based on other 2 columns?
I’m trying to get the max and min date values in column C based on the (column A, column B) unique pair combinations. Suppose I have a table like: The output I want to get is: My attempt query has been taking 20 mins to run with no output yet (just tried to get max date from column C for
For each ID get the first record where Product is not null (Postgresql)
I have customer data with information when the appointment took place, what type of appointment it was and wheather a Product was selected. I am trying to get the earliest appointment for every id where Product is not null. Basically reduce the table where id only appears once with appointment date and type where product is not missing. This doesn’t
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
I’m looking for a pair of SQL functions (MS SQL Server) that will return the MAX or MIN of a list of dates
I’m looking for a pair of SQL functions that will return the MAX and MIN value of a list of dates (or, alternatively, the MAX and MIN of two dates – I can then stack the calls to handle the whole list)…
Selecting different parameters for a group by statement in mysql?
I have a dataset like this: Here in this dataset, there is No NULL value for all these 3 columns, also user_name and recording_msid pair can repeat but each repeated pair will have a distinct …
select * from [table] where min(date) > certain date
i have a table with customers. every customers has several orders with the paid price and day he/she ordered an item. i want only customers their first order was after a certain date orders table …