borderAndreaVB free resources for Visual Basic developersborder

borderAndreaVB Visual Basic and VB.NET source code resources - Copyright © 1999-2007 Andrea Tincaniborder

AndreaVB | Forum | News | Downloads | Register | Help | Member List | Statistics | Search | PM | Profile

Print This Topic
Previous Topic (Find the second largest salary from emp table)Next Topic (sql problem) New Topic New Poll Post Reply
AndreaVB Forum : Database : select distinct
Poster Message
tnguyen33
Level: Guest


icon select distinct

Hello all,
Please help me,,,
below is the code:;

when i use:

SELECT DISTINCT Treatment.ClientID, Treatment.StartDate
FROM Treatment;

it shows only 423 records, but when i use

SELECT DISTINCT Treatment.ClientID, Treatment.StartDate, Treatment.TypeRX FROM Treatment;
it shows 485 records

I would like to select distinct only first 2 fields(Treatment.ClientID, Treatment.StartDate) however the third field (Treatment.TypeRX) I want it still show in the query(not select distinct this field)...How can i do it? Does anyone know please help...I'm very appreciated...thanks alots

06-01-2003 at 04:33 PM
| Quote Reply
JLRodgers
Level: Moderator

Registered: 04-04-2002
Posts: 1617
icon Re: select distinct

Offhand, you do have to condiser something:

F1 F2 F3
A  B  C
A  B  D
A  C  B
B  D  C

Distinct F1, F2 would be:
A B
A C
B D

Distinct F1, F2, F3 would be:
A B C
A B D
A C B
B D C

If you want output like the distinct f1,f2, which record are you expecting it to not display in the distinct f1,f2,f3?

Even with making one query with the distinct results, and then showing only those records in the original table that there's a match, the same output would result (I believe, since A B would be compared, A B C, and A B D would both match).




[Edited by JLRodgers on 06-01-2003 at 12:51 PM GMT]

____________________________
Everywhere's Local (classifieds, job postings, & more for everycity in the world - user entered)

06-01-2003 at 06:50 PM
View Profile Send Email to User Show All Posts Visit Homepage | Quote Reply
tnguyen33
Level: Guest

icon Re: select distinct

Oh I understood now, thanks alots

09-01-2003 at 03:54 PM
| Quote Reply
AndreaVB Forum : Database : select distinct
Previous Topic (Find the second largest salary from emp table)Next Topic (sql problem) New Topic New Poll Post Reply
Surf To:


Not Logged In? Username: Password: Lost your password?
Partners: Download Actual Software | Free Software Download
borderAndreaVB free resources for Visual Basic developersborder

borderAndreaVB Visual Basic and VB.NET source code resources - Copyright © 1999-2007 Andrea Tincaniborder