All Questions
20 questions
0
votes
1
answer
44
views
eliminating a whole group which doesn't meet minimum date - SQL Spark
I have a table with order ID, Country, order date, product name and quantity. As you can see one unique order ID is composed of a few products/records but spread around different dates. I need my ...
2
votes
3
answers
817
views
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:
column_A column_B column_C
A 1 2019-08-...
0
votes
1
answer
1k
views
select the SECOND highest value for each group in mySQL 5
this code gets id and latest timestamps for each ID
select id, max(start_time) as start1, max(end_time) as end1 from table group by id
how do I get the second highest timestamps as start2 and end2?
0
votes
3
answers
196
views
Find Max value and assign the value by group by id for non numeric field
I am trying to assign the max value by grouping id field. If the id has L and M the result should be M, if the id field has L, M and H the result should be H. If it has only one value, the same value ...
0
votes
1
answer
58
views
After an ORDER BY get the first item in MySQL
I'm using a GROUP BY to display general info from a table.
SELECT * FROM table GROUP BY Continent
Datas are the following ones:
|--------|-----------|-----------|
| Id | Continent | Fruits |
|-...
0
votes
2
answers
379
views
use min() and avg () in subquery
I'm working on db2 from ibm cloud and sql.
My data contains 1 table with 3 columns: schools, their overall performance (level) and location.
I want to find the location with the least AVERAGE level ...
-1
votes
1
answer
111
views
I am getting a "Identifier identifier" error when executing a SQL query
I am not sure how to fix the error that is referring to enrollment.student_id
SELECT std_name, course#
FROM student
INNER JOIN (SELECT min(grade) FROM enrollment GROUP BY grade)
ON enrollment....
0
votes
1
answer
292
views
LeetCode #512 Game Play Analysis MySQL
I was doing this question LeetCode #512
The original code I wrote was:
select a.player_id, a.device_id from
(select player_id, device_id, min(event_date)
from Activity
group by player_id) a
My logic ...
1
vote
2
answers
169
views
sql - Get the Minimum Value of 2 subqueries
I have a query which has 5 subqueries. I need it to have only 4 subqueries, since two of them are supposed to be only one result. The problem is I don't know how to maintain the query structure and ...
0
votes
1
answer
2k
views
Select Min Date value from subquery to main query
I'm trying to get the min Date value as a column in the main query where the main query & the subquery have inner joins & the min Date value is dependent on grouping of 3 columns from the main ...
0
votes
3
answers
182
views
MySQL SELECT-query: How can I get the right ID when using the MIN()-function in my query?
I'm programming a C# Windows Forms Application in Visual Studio and I'm trying to get data about minimum prices of products in supermarket2 and supermarket 3 from shopping lists.
The first step I need ...
-1
votes
2
answers
66
views
Subquery using min function in sql
Here is the schema
author (aID, fName, surname)
book (isbn, title, authorID, genre, pubYear, publisher,rrPrice, avgRating)
bookShop (shopNo, shopName, street, city, county)
orders (orderNo, sNo, ...
0
votes
1
answer
190
views
Select row with min value of element (if single/multiple rows are present in table)
Sample table -
rollno | subj_code | priority
1 | c45 | 0
1 | b68 | 1
1 | a98 | 2
2 | a98 | 0
I want to select a row with min value of priority for that I'm ...
1
vote
3
answers
42
views
Learning SQL: Need help Using HAVING to get the MIN result from an aggregate
was hoping to get some help. New to SQL and trying to keep my head on straight.
I've been given this assignment:
"Using HAVING, determine whose Direct Reports have the lowest Avg Salary."
My logic ...
1
vote
3
answers
1k
views
Getting all row data from minimum value in a field in a SQL query (Oracle)
I'm having trouble obtaining a row of all information from a SQL query by specifying the minimum value of a field. Below is a basic example of the data I'm using and what I am trying to obtain:
...