Home » RDBMS Server » Server Administration » Only want one of the records in a query.
Only want one of the records in a query. [message #370896] Fri, 03 March 2000 01:41 Go to next message
kat
Messages: 15
Registered: February 2000
Junior Member
Hi,
let me start with an example, I will write
"select address from tblCustomer where lastname='White'"
This can result in a query with more than one record.
But I only want one of them, doesnt matter which customer's address, as long as the last name of the customer is "White". Is it possible at all? Any idea? Thanks in advance.
Re: Only want one of the records in a query. [message #370909 is a reply to message #370896] Sun, 05 March 2000 19:59 Go to previous messageGo to next message
Yasu
Messages: 2
Registered: March 2000
Junior Member
Examples are

select address from tblCustomer where lastname='White' and rownum=1
only 1 is possible

or

select address from
(
select address,rownum as NO from tblCustomer where lastname='White'
)
where NO=n[[n=1,2,...N]]
Re: Only want one of the records in a query. [message #370910 is a reply to message #370896] Mon, 06 March 2000 01:15 Go to previous messageGo to next message
Atavur Rahaman S.A
Messages: 23
Registered: January 2000
Junior Member
Hope this will help you in all the way...

SQL> Select C.Customer_No, C.Customer_Name, C.Customer_Addr from Customer C where C.Customer_No NOT IN (Select DISTINCT B.Customer_No from Customer B where B.Customer_Address

Query to display the unique records with one address...

SQL> Select C.Customer_No, C.Customer_Name, C.Customer_Addr from Customer C where C.Customer_No NOT IN (Select DISTINCT B.Customer_No from Customer B where B.Customer_Address
Regards
Atavur
Re: Only want one of the records in a query. [message #370917 is a reply to message #370896] Mon, 06 March 2000 16:24 Go to previous message
Edward Jayaraj
Messages: 7
Registered: December 1999
Junior Member
Isn't it simple and smart :

"SELECT MAX(address)
FROM TblCustomer
WHERE lastname='White'"

Let me know if there is any problem
Thanks
Previous Topic: Thanks for the reply, Frank Naude
Next Topic: LEFT JOIN, RIGHT JOIN syntax in Oracle - Urgent!!!!
Goto Forum:
  


Current Time: Thu Oct 22 05:00:54 CDT 2020