Home » RDBMS Server » Server Administration » Distinct records based on comp_code column
Distinct records based on comp_code column [message #374225] Thu, 31 May 2001 04:13 Go to next message
adnan
Messages: 15
Registered: May 2001
Junior Member
hi,
i have a table which has three columns
comp_code,officetype,address
the record is unique only if the values of all the three columns are taken.I want to display records such that the comp_code is not repeated ie for one comp_code i want to display the record only once, no matter which record.
I want to do this through one sql.
Please help !!!
Re: Distinct records based on comp_code column [message #374233 is a reply to message #374225] Thu, 31 May 2001 13:29 Go to previous message
Andrew again...
Messages: 270
Registered: July 2000
Senior Member
Tyy something like this. Max or Min can be used. Don't interpret any meaning the whether a rowid selected in the min or max - it does not translate the the easriest or latest record.

select * from my_table t1
where t1.rowid in (select max(t2.rowid)
from my_table t2
group by comp_code,officetype,address)
Previous Topic: cursor and function
Next Topic: group by clause
Goto Forum:
  


Current Time: Mon Dec 23 13:04:15 CST 2024