Home » SQL & PL/SQL » SQL & PL/SQL » Retrieve one record for one id (Oracle 10g)
Retrieve one record for one id [message #331372] Thu, 03 July 2008 03:25 Go to next message
rajat_chaudhary
Messages: 141
Registered: November 2006
Location: india
Senior Member

Hi Experts

My query result is like given below

ID    Name      City    Country   PrimaryAddress
1    Rajat      Delhi    India      Y
1    Chaudhary  Delhi    India      Y
2    Utkarsh    Delhi   India       Y
3    Ahmer      Gurgaon India       N
1    Rajat      Delhi    India      Y


My question is to get only 1 record for one ID.
I use Inline query also but I can't retrieve my required recoprd set.
So please help me to get out of this.

Regards
Rajat
Re: Retrieve one record for one id [message #331373 is a reply to message #331372] Thu, 03 July 2008 03:33 Go to previous messageGo to next message
Frank
Messages: 7880
Registered: March 2000
Senior Member
use distinct.

After you get your result, read up on some relational database concepts.
Having multiple rows that are exactly the same should never happen.
Re: Retrieve one record for one id [message #331377 is a reply to message #331373] Thu, 03 July 2008 03:44 Go to previous messageGo to next message
rajat_chaudhary
Messages: 141
Registered: November 2006
Location: india
Senior Member

Please see the attachments to know the exact record set.

from this record set i want to get only one record for 1 id.

Note :- Distinct doesn't work here
Re: Retrieve one record for one id [message #331378 is a reply to message #331377] Thu, 03 July 2008 03:47 Go to previous messageGo to next message
Frank
Messages: 7880
Registered: March 2000
Senior Member
Which record should be returned for id 1?
Re: Retrieve one record for one id [message #331381 is a reply to message #331378] Thu, 03 July 2008 03:53 Go to previous messageGo to next message
rajat_chaudhary
Messages: 141
Registered: November 2006
Location: india
Senior Member

The top one for any id's
Re: Retrieve one record for one id [message #331386 is a reply to message #331381] Thu, 03 July 2008 04:00 Go to previous messageGo to next message
Frank
Messages: 7880
Registered: March 2000
Senior Member
Which is the top one, if all fields are equal?
Re: Retrieve one record for one id [message #331394 is a reply to message #331386] Thu, 03 July 2008 04:11 Go to previous messageGo to next message
rajat_chaudhary
Messages: 141
Registered: November 2006
Location: india
Senior Member

If all the fields are equal then only one record
Re: Retrieve one record for one id [message #331399 is a reply to message #331381] Thu, 03 July 2008 04:31 Go to previous messageGo to next message
Michel Cadot
Messages: 64152
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator
rajat_chaudhary wrote on Thu, 03 July 2008 10:53
The top one for any id's

Define "top one".

Regards
Michel

Re: Retrieve one record for one id [message #331407 is a reply to message #331394] Thu, 03 July 2008 04:40 Go to previous message
Frank
Messages: 7880
Registered: March 2000
Senior Member
rajat_chaudhary wrote on Thu, 03 July 2008 11:11
If all the fields are equal then only one record

And which is the top one if not all fields are equal?

Without an order by, there is no such thing as a 'top one', or first, or last.
Previous Topic: Update Column with auto increment
Next Topic: insert in query ?
Goto Forum:
  


Current Time: Sat Dec 10 10:53:13 CST 2016

Total time taken to generate the page: 0.06126 seconds