Questions tagged [max]
Finding the maximum value in a group of items
67 questions
0
votes
1
answer
175
views
Did performance when querying partitioned tables using min/max functions or TOP improve after SQL Server 2022?
With partitioned tables in SQL Server, there is a notorious major performance issue when using using min/max functions or TOP. Microsoft document workarounds for it here. I am confident that this was ...
-3
votes
3
answers
89
views
Max Field from Grouped Table
I have a grouped table that looks like this:
End_of_Month_Date
VersionId
2024-06-30
1
2024-06-30
2
2024-07-31
1
2024-07-31
2
2024-07-31
3
2024-07-31
5
For each month end, I want to pull in the Max(...
2
votes
2
answers
2k
views
Ignore duplicate rows in a join - and take only one of them
In MySQL I have tables, simplified as follows:
companies (id, name, rank, trade_sector_id)
orders (id, company_id, paid, subtotal)
trade_sectors (id, label)
companies_notes (id, company_id, notes)
I ...
0
votes
0
answers
490
views
Find maximum of 'jsonb_path_query_array' output
I'm using postgres with a jsonb field that looks something like this:
{[[1.2, 'blah'], [3.4, 'blahhh']}
I'm extracting the numbers by using:
jsonb_path_query_array(json_row, '$[*][0]')
Which gives ...
0
votes
2
answers
291
views
Selecting last value to be entered each month
I am looking to pull a closing balance from the database for each month.
I have tried
SELECT CloseBal As 'Balance', MONTHNAME(DateTime) as 'Month', DateTime
FROM Table1
WHERE MAX(DateTime)
Group By ...
0
votes
0
answers
123
views
Overlap on Max/Min dates
I have data in a table that has gotten cut up with multiple start and end dates. This is due to an error that has happened a few times in the last year. Apparently causing the system to not see the ...
1
vote
1
answer
225
views
Query for MAX/MIN of non-clustered index field for partitioned table
We have a table partitioned on a two-year based hash function from the system date at the insertion time (let's call it PartitionKey). It also has a non-clustered index on a single field (Key). We ...
0
votes
2
answers
641
views
What if we do not use MAX function
I was supposed to use a script to get the MAX value from a table. It should have looked like this
BEGIN
DECLARE @MaxID AS INT
SELECT @MaxID = MAX([Id]) FROM dbo.suggestion
Insert into suggestion
...
1
vote
1
answer
394
views
How to filter results by specifying the criteria you want the MAX date stamp for?
Please bear with me as I am a beginner and could not find this answer elsewhere. I am working with employee data and need to determine which Product Group a given Team was associated with on the last ...
-1
votes
2
answers
236
views
How to write query to select highest value from same date
please help me write this query for MySQL.
I want to select highest value from same datetime. So if there are multiple equal datetime value, return only one row with highest price.
For summary, one ...
4
votes
2
answers
37k
views
How to retrieve the maximum value and its corresponding date in a table
I'm trying to figure how to retrieve minimum/maximum values and minimum/maximum dates from a data set, but also the date value that corresponds to each minimum/maximum value.
Example Data
CREATE TABLE ...
1
vote
2
answers
5k
views
How to get the second highest value per group?
Getting the second highest value from a table has been solved many times, but I'm looking for the second highest value in each group.
Given this table:
+----+-----+
| A | 10 |
| A | 20 |
| A | ...
0
votes
3
answers
312
views
Statement of total precipitation for each hour, day or month
I store the data from the rain gauge in mySQL and needed help with listing the data. I save the data every 5 minutes and use the save date in the form of a timestamp.
At the end of each hour, ...
0
votes
3
answers
308
views
Find Max() updated time for a group of users
Database is MariaDB 10.3.25
I have 2 columns that are relevant:
UserID and LastUpdate
UserID consists of user@domain
LastUpdate is a date field.
Here is my issue - I have the current query:
select a....
2
votes
2
answers
3k
views
Choosing values from multiple columns based on latest value of one column
I have an Azure Cosmos DB that contains columns DateTime, userName, temperature, and bloodPressure, plus many other columns. There are several distinct userName values, and each userName has ...