Linked Questions
385 questions linked to/from Fetch the rows which have the Max value for a column for each distinct value of another column
225
votes
6
answers
557k
views
GROUP BY with MAX(DATE) [duplicate]
I'm trying to list the latest destination (MAX departure time) for each train in a table, for example:
Train Dest Time
1 HK 10:00
1 SH 12:00
1 SZ 14:...
26
votes
2
answers
51k
views
Select First Row of Every Group in sql [duplicate]
I have two tables .
1-> SM_Employee
(1) employeeid
(2) roleid
(3) storeid
2-> SM_SalesRepWorkflow
(1) workflowid
(2) Salesrepid foreign key to employeeid
(3) QuantityAssigned
(4) ...
26
votes
2
answers
55k
views
Oracle SQL query: Retrieve latest values per group based on time [duplicate]
I have the following table in an Oracle DB
id date quantity
1 2010-01-04 11:00 152
2 2010-01-04 11:00 210
1 2010-01-04 10:45 132
2 2010-01-04 10:45 318
4 ...
12
votes
5
answers
34k
views
How to get the max value for each group in Oracle? [duplicate]
I've found some solutions for this problem, however, they don't seem to work with Oracle.
I got this:
I want a view to present only the informations about the oldest person for each team. So, my ...
8
votes
4
answers
20k
views
Oracle Analytic function for min value in grouping [duplicate]
I'm new to working with analytic functions.
DEPT EMP SALARY
---- ----- ------
10 MARY 100000
10 JOHN 200000
10 SCOTT 300000
20 BOB 100000
20 BETTY 200000
30 ALAN 100000
30 TOM ...
10
votes
3
answers
26k
views
Return row with the max value of one column per group [duplicate]
I am having a hard time doing this without searching the same table at least twice in order to grab the max row, and then grab the value for that row. The table in question is quite big so this is ...
9
votes
1
answer
11k
views
Get value based on max of a different column grouped by another column [duplicate]
I want to get the values of a column based on max of a different column grouped by another column.
I have this table:
KEY NUM VAL
A 1 AB
B 1 CD
B 2 EF
C 2 GH
C 3 HI
D 1 JK
D ...
5
votes
6
answers
8k
views
How to return only latest record on join [duplicate]
I'm joining tables. I only want to return one record from the joining table, based on a date field.
Here's a simplified fiddle of what I've done so far: http://sqlfiddle.com/#!3/be0cdd/2
My tables:
...
1
vote
3
answers
14k
views
How to select max date using SQL without using group by clause . There are solutions for this which have group by clause I want solution without it [duplicate]
I've following table:
PERSON_ID EFFECTIVE_END_DATE ASSIGNMENT_ID FULL_NAME
33151 2013-08-04 00:00:00.0 33885 Test, C
33151 2013-10-04 00:00:00.0 33885 ...
3
votes
2
answers
4k
views
SQL: getting the max value of one column and the corresponding other columns [duplicate]
ID| tag | version
-----+-----+-----
1| A | 10
2| A | 20
3| B | 99
3| C | 30
3| F | 40
desired output:
1 A 10
2 A 20
3 B 99
How can I get the max version of every ID and the ...
-1
votes
4
answers
10k
views
SQL select to display latest record [duplicate]
So here is a case where one of the column in a table has same values for multiple records but the Date column has incremental values.
ID| PAY_CODE| RATE | Date
---------------------------------
1 ...
1
vote
2
answers
3k
views
How to fetch the most recent timestamped record for the same id from MySQL table? [duplicate]
Possible Duplicate:
Fetch the row which has the Max value for a column
I have an audit table of people and the number of shares they own at a particular timestamp. How do I fetch the most recent ...
0
votes
2
answers
6k
views
showing the details of the student with the maximum marks in oracle 11g R2 [duplicate]
goal
I have a student table. I need to show the details viz. name of the student who has obtained the maximum marks in a test.
definition of the tables
the following is the code for the definition ...
0
votes
3
answers
3k
views
Retrieve max date for distinct IDs in a table [duplicate]
I have the table ABC with the following data
Id Name Date Execution id
-- ---- --------- -------------
1 AA 09SEP2019 11
1 AA 08SEP2019 22
1 AA 07SEP2019 33
...
-1
votes
2
answers
4k
views
least date in oracle sql [duplicate]
Sample table:
Hi, can someone pl. help how do I get the least date and corresponding name from the table above? I should get only 3 rows, with first one as Ram and second one as def and third one as ...