I need to select all records from a table but exclude any duplicates.
eg Table Tickets Field "reg" contains:
ticket No Reg
1 xy123
2 xy123
3 ab123
4 bc123
5 bc123
I need to return
ticket No Reg
1 xy123
3 ab123
4 bc123
Cheers
SteveW
> I need to select all records from a table but exclude any duplicates.
SELECT DISTINCT * FROM dont_know
--
stefan
> In article <46388c7e$1...@newsgroups.borland.com>, SteveW says...
>
> > I need to select all records from a table but exclude any duplicates.
>
> SELECT DISTINCT * FROM dont_know
No, this would probably return nothing, don't know, sorry.
--
stefan
Hi Steve
try
select min(q1."ticket No"), q1."Reg"
from Tickets q1
group by q1."Reg"
This should give you the grouping on the Reg field and will return the
lowest Ticket no value for the group value Reg.
Tom
--
This question was posted and answered in b.p.d.database.sqlservers.
You are aware of the posting guidelines and apologise *in advance* for your
misuse, yet still choose to ignore them for your own convenience. I doubt
your mother would approve of such behavior.
--
Ray Marron
What if she did...?
SELECT T1.Reg, T2.Reg, RECID
from Table1 T1, Table1 T2
where T1.RECID = T2.RECID
and T1.Reg <> T2.Reg;
--
Tony Caduto
AM Software Design
Home of Lightning Admin for PostgreSQL and MySQL
http://www.amsoftwaredesign.com