Skip to main content

All Questions

Tagged with
Filter by
Sorted by
Tagged with
-2 votes
1 answer
102 views

Detect and ignore anomalous number in MySQL MIN/MAX query [closed]

I am trying to find the MIN and MAX of a simple data set.... Score 15 12 8 28 5 Simply doing this would work. SELECT MIN(Score) AS minScore, MAX(Score) AS maxScore FROM Scores; Which should return 5 ...
ihatzi's user avatar
  • 17
0 votes
2 answers
560 views

Having trouble using MIN() in having clause

Trying to select earliest order_date for each customer_id. Using following query SELECT customer_id, order_date FROM Delivery GROUP BY customer_id HAVING MIN(order_date) = order_date But ...
BenS's user avatar
  • 23
0 votes
2 answers
47 views

MYSQL Min Max Historic Values

I have a MYSQL table with this format: Insurance Date Value A 2020-01-01 2 A 2020-02-01 5 A 2020-03-01 4 A 2020-04-01 6 A 2020-05-01 8 A 2020-06-01 1 A 2020-07-01 3 A 2020-08-01 7 A 2020-09-01 9 A ...
Dabi's user avatar
  • 3
0 votes
1 answer
60 views

MySql query tuning for min/max dates by group

I have a table with several million rows of data. I have a primary key on id, and a compound unique key on col2, col3, col4 and my_date. Sample data is shown here... id col2 col3 col4 my_date 1 1 ...
Wannabe-Coder's user avatar
0 votes
3 answers
1k views

Get MIN, MAX, AVG value with datetime for each DAY (MySQL)

I have a MySQL database with lots of entrys with columns like "local_time", "temp", "wind", etc. What I want to archive is get in just one query the MIN value for temp, ...
cbn's user avatar
  • 31
0 votes
3 answers
359 views

How to select the row with the minimum value of a column while the other column is at its maximum? [closed]

In SQL, how can I select the minimum value of a column a (integer) where the column b (integer) is the maximum value for that column, using only one select ? SELECT MIN(a) OVER (PARTITION BY MAX(b)) ...
Victor's user avatar
  • 375
0 votes
1 answer
81 views

SQL WHERE function filter-unexpected answer

The problem looks like this: Write an SQL query that selects the product id, year, quantity, and price for the first year of every product sold. Return the resulting table in any order. A simple ...
mmmmmm's user avatar
  • 63
3 votes
1 answer
677 views

How to count new users by min date without using a subquery?

I have an event table in which each user has several dates registered. The minimum date for each user would be the join_date for each user. I need to do a count for each user for each min date (...
Luis M. Corral's user avatar
1 vote
2 answers
720 views

MYSQL - get three or more consecutive rows by time (on same date) where amount is minimum

I have a database with the following columns. I have added some sample data to show formatting. date, time, amount 2021-10-14, 13:00, 15.40 2021-10-14, 13:01, 9.34 2021-10-14, 13:02, 10.12 2021-10-14, ...
Alexnl's user avatar
  • 477
1 vote
2 answers
48 views

Group by multiple fields after SQL join

I have written the following query which correctly joins two tables which shows the number of completed tasks by individuals in a team and the associated cost of those tasks: SELECT users.id AS ...
ojp's user avatar
  • 1,033
0 votes
0 answers
43 views

MIN() not getting the lowest value when there's a decimal in php mysql query

still not solved I want to return the total cost of each supplier with the lowest price. the total cost is acquired by getting the sum of the product of item quantity and unit cost. This is my current ...
cba's user avatar
  • 1
0 votes
2 answers
43 views

How to select multiple MIN record of table that inner joinned with other 3 table based on other table parameter(s)?

I have a question. I have 4 tables: product_list product product_img pricelist This what my query looks like: SELECT product_list.id, product_list.class, product.prod_name, product.prod_url, ...
Willie Sandi's user avatar
1 vote
1 answer
848 views

How to get time difference between MIN timestamp and MAX timestamp

I'm trying to get the MAX & MIN Timestamp for the certain time frame. As you can see here: I will use mysql or pl/sql Is it possible to get it? Example: Black block: 11/2/2022 05:45:28 ~ 11/2/...
Isyraf Fikri's user avatar
0 votes
1 answer
802 views

group by ID and filter by condition - if something then mark them as something else

On my query right now I'm receiving and ID that can be repeated and the status, so I want to group by ID but if any of the rows has status ACTIVE then it should appear ACTIVE. I have something like ...
Tonino Fernandez's user avatar
0 votes
1 answer
347 views

select the min value of a id from other table

I want to select the min value of a id from other table here my table1 id grades 1 1 2 2 1 3 1 4 2 5 my table2 id name 1 andy 2 lucy 3 kevin I tried this select table2.id, name, min(table1.grades) as ...
leo's user avatar
  • 3

15 30 50 per page
1
2 3 4 5
22