All Questions
485 questions
-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 ...
0
votes
1
answer
47
views
Max and Rank not returning expected results
I have what I thought was a simple solution to return the earliest date in each group for a large number of records.
WITH FEES
AS
(
SELECT
IT_NO AS ITEM_NO,
MAX(FEE_TRAN_DT) ...
-3
votes
1
answer
54
views
I am trying to figure out how to incorporate a date range restriction while using the MIN function in SQL [closed]
I have a list of order dates for various vendors on specific items. I want to be able to pull the MIN orderdate but also have the min order date be within a specific date range (i.e. first day of last ...
2
votes
2
answers
80
views
Teradata Windows analytical function to select the correct records from partition
I have just 2 columns for partition and on basis of those two columns, need to select the appropriate dates.
Input Data:
strt_dt
end_dt
ID
Amt
2023-09-29
2023-10-01
ID1
100
2023-10-02
2023-10-02
ID1
...
0
votes
3
answers
66
views
Select all value except min value and add corresponding min value in another column
Consider this table:
id
text
101
Black
102
Black
103
White
104
White
105
White
How one could select all the ids except the min id, but also add the corresponding min value in another column? So the ...
0
votes
1
answer
35
views
SQL Problem : Use min and max in chronological groups
I would like to know if it is possible to group ONLY in chronological order and display the min and max according to the groups.
An example :
TYPE
Start_dath
End_dath
TL1
01/01
31/01
TL1
01/02
29/02
...
0
votes
1
answer
35
views
Adding min qty on running total per day
I have a query that gives the running total of stock less sales on a daily basis and need to show the min available quantity to ensure that sales do not oversell.
In Excel I can run min on a range, ...
1
vote
1
answer
57
views
return the Min and Max()row_number that is found spark SQL
select distinct
snap1.rn,
snap2.rn1,
snap1.doc_num
from (select DISTINCT *,
row_number() over (partition by car_id order by SNAPSHOT_DATE, CAR_ID) rn
from MY_TABLE
)snap1
left join
(select DISTINCT ...
0
votes
1
answer
69
views
MIN() in JOIN based of dates
I would like to join two tables based on two common fields. Assume the date is 2024 I want to join the sale table on dictionary table which hold only articles with dates 2022 and 2023. Because of the ...
1
vote
3
answers
63
views
Min dates from group by postgresql
I have table with data:
create table measure_app_scalemeasurement (
store_code text,
certificate_id text,
audit_ending date);
insert into measure_app_scalemeasurement values
('K010','vwv', '10....
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 ...
0
votes
1
answer
68
views
MAX amd MIN events by hour between two dates
I have a transactional table with the transaction's timestamp and other columns, like this.
transaction_timestamp | column_1 | column_2....
--------------------------------------------------
2023-01-...
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 ...
1
vote
1
answer
186
views
PostgresSQL- find 3 lowest values based on another column [duplicate]
I am challenging this issue. I have a table that calls: results. There are 3 columns and it looks like below (id column is int, city is varchar, score is int):
id name score
1 x 5
2 x ...
0
votes
2
answers
64
views
How to get MIN(opened_date) and all Open Records
I have some data that looks like this:
Number
CI
PLUGIN
Opened Date
State
1
XYZ
A123
1/1/2023
Closed
2
XYZ
A123
2/1/2023
Closed
3
XYZ
A123
3/1/2023
Closed
4
XYZ
A123
4/1/2023
Open
5
XYZ
A123
5/1/2023
...