Home » SQL & PL/SQL » SQL & PL/SQL » Need an Query idea (merged 3)
Need an Query idea (merged 3) [message #418997] Wed, 19 August 2009 09:30 Go to next message
sganezz
Messages: 3
Registered: August 2009
Location: London
Junior Member

Friends,

I have the table like below

Name Priority
A 1
B 1
C 1
A 2
B 3
C 3
D 4



From which i need to pick the name and high priority record. (i.e. 1 is high priority and 4 is low priority)

The result set needs to be the below

Name Priority
A 1
B 1
C 1
D 4

Thanks for your time. Help me kindly
Re: Need an Query idea [message #418998 is a reply to message #418997] Wed, 19 August 2009 09:33 Go to previous messageGo to next message
cookiemonster
Messages: 12422
Registered: September 2008
Location: Rainy Manchester
Senior Member
you need to use MAX and GROUP BY
Re: Need an Query idea [message #419000 is a reply to message #418997] Wed, 19 August 2009 09:36 Go to previous messageGo to next message
BlackSwan
Messages: 25047
Registered: January 2009
Location: SoCal
Senior Member
You need to help us by following the Posting Guidelines as stated below.
http://www.orafaq.com/forum/t/88153/0/
Go to the URL above click the link "Posting Guidelines"
Go to the section labeled "Practice" & do as directed.


use MIN() function
Re: Need an Query idea [message #419002 is a reply to message #418998] Wed, 19 August 2009 09:41 Go to previous messageGo to next message
BlackSwan
Messages: 25047
Registered: January 2009
Location: SoCal
Senior Member
cookiemonster wrote on Wed, 19 August 2009 07:33
you need to use MAX and GROUP BY



>From which i need to pick the name and high priority record. (i.e. 1 is high priority and 4 is low priority)
MAX?
Re: Need an Query idea [message #419003 is a reply to message #418997] Wed, 19 August 2009 09:44 Go to previous messageGo to next message
cookiemonster
Messages: 12422
Registered: September 2008
Location: Rainy Manchester
Senior Member
Ok, so my brain lept straight to the answer after reading highest priority. I'd like to hope the OP can work it out from that though.
Re: Need an Query idea (merged) [message #419006 is a reply to message #418997] Wed, 19 August 2009 09:56 Go to previous messageGo to next message
Michel Cadot
Messages: 64140
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator
Next time before posting please read OraFAQ Forum Guide, especially "How to format your post?" section.
Make sure that lines of code do not exceed 80 characters when you format.
Indent the code (See SQL Formatter), use code tags and align the columns in result.
Use the "Preview Message" button to verify.
Also always post your Oracle version with 4 decimals.

And post a working Test case: create table and insert statements along with the result you want with these data.


Regards
Michel
Re: Need an Query idea [message #419071 is a reply to message #418997] Wed, 19 August 2009 14:33 Go to previous messageGo to next message
BlackSwan
Messages: 25047
Registered: January 2009
Location: SoCal
Senior Member
http://www.orafaq.com/forum/m/418997/136107/#msg_418997

Do NOT cross/multi-post!

You need to help us by following the Posting Guidelines as stated below.
http://www.orafaq.com/forum/t/88153/0/
Go to the URL above click the link "Posting Guidelines"
Go to the section labeled "Practice" & do as directed.
Re: Need an Query idea (merged) [message #419073 is a reply to message #418997] Wed, 19 August 2009 14:40 Go to previous messageGo to next message
BlackSwan
Messages: 25047
Registered: January 2009
Location: SoCal
Senior Member
>Biography: Sr.Oracle DBA
REALLY?
Re: Need an Query idea [message #419124 is a reply to message #418997] Wed, 19 August 2009 23:51 Go to previous messageGo to next message
ayush_anand
Messages: 417
Registered: November 2008
Senior Member
You can use 'MIN function' and 'group by' as one of the ways to achieve your functionality
Re: Need an Query idea [message #419125 is a reply to message #418997] Wed, 19 August 2009 23:56 Go to previous message
BlackSwan
Messages: 25047
Registered: January 2009
Location: SoCal
Senior Member
http://www.orafaq.com/forum/m/419073/136107/#msg_419000
asked & answered many hours ago
Previous Topic: how to get two different dates difference in day/hour/min/sec please
Next Topic: Execute immediate inside a Loop (Merged 4)
Goto Forum:
  


Current Time: Fri Dec 09 09:41:32 CST 2016

Total time taken to generate the page: 0.06628 seconds