Home » SQL & PL/SQL » SQL & PL/SQL » How to select distinct coloumns??
How to select distinct coloumns?? [message #20167] Fri, 03 May 2002 02:13 Go to next message
sandeep
Messages: 110
Registered: October 2000
Senior Member
Hi,
Can anyone help me with the following prob i am facing:
I have table with entries as---
CustNum Firstname LastName VehNum
001 ABC DEF 1234
001 ABC DEF 6789

Above table implies there is one customer owning 2 vehicles.
Now problem is i want a list of customer ignoring how many vehicles they own.How do i do it? Cuz 'distinct' doesnt work on coloumn level.
I have searched a lot everywhere......nebody has ne idea on this?
Re: How to select distinct coloumns?? [message #20170 is a reply to message #20167] Fri, 03 May 2002 05:49 Go to previous messageGo to next message
Jon
Messages: 483
Registered: May 2001
Senior Member
What do you mean, distinct doesn't work on column level?
09:40:22 ==> select * from tabletest;

CUSTNUM FNAME LNAME
--------- -------------------- --------------------
1 Joe Smith
1 Joe Smith
2 Salli Jones
4 Fred Mertz
1 Mark Jones

09:40:58 ==> select distinct custnum, fname, lname from tabletest;

CUSTNUM FNAME LNAME
--------- -------------------- --------------------
1 Joe Smith
1 Mark Jones
2 Salli Jones
4 Fred Mertz
Re: How to select distinct coloumns?? [message #20193 is a reply to message #20167] Mon, 06 May 2002 07:36 Go to previous message
Bisor
Messages: 2
Registered: May 2002
Junior Member
select CustNum, firstname, lastname max(VehNum) as Vehnum from table1 group by CustNum, firstname, lastname

can give you a distinct info with an arbitrary Vehnum
Previous Topic: Re: how to give the ranks to the students?
Next Topic: Re: update multiple fields
Goto Forum:
  


Current Time: Fri Apr 26 18:11:45 CDT 2024