-
Oracle Find Minimum from temp table
I have a select statement that returns a list of users ids and and a numberic value column we will call X. Each user can have one or many values for X. I need to do a secondary select from the temp table to get the least value for each useid for their value of X
how does one do this in Oracle SQL
example temp table
userid X
JJ 2
RJ 5
TL 3
TL 7
RJ 2
JB 8
I would want to get
JJ 2
RJ 2
TL 3
JB 8
Thanks in advance
-
Not sure what you want exactly, this will give you min value.
select userid, min(x)
from temp
group by userid
if you need to use it to get more data from temp then you can do
select a.*
from temp a
join (
select userid, min(x) x
from temp
group by userid) b
on a.userid=b.userid and a.x=b.x
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
|