Actually distinct applies to the whole select clause. Both "Select
distinct table1.studentID, table2.goalID" and "Select
table1.studentID, distinct table2.goalID" should return the same
recordset.
also...
> SELECT DISTINCT
table1.studentID, table2.goalID
> FROM table1,
table2
> WHERE table1.studentID =
table2.studentID
the
distinct behavior...
I believe this should pull back a distinct studentID
meaning which ever goalID it come to first is the one you see unless
ordered. You should only get 1 studentID per student on this distinct
select.
so your group by would look
like:
SELECT
table1.studentID, table2.goalID (no need
for distinct in a group by - in fact it should give you an
error)
FROM table1,
table2
WHERE table1.studentID =
table2.studentID
HAVING (if desired)(does NOT have to be part of the
select)
GROUP BY table1.studentID,
table2.goalID
ORDER BY table1.studentID, table2.goalID (If Desired)
NOTE: The fields in the group by must match the
selected. so if you say trim(field) in the select you must say
trim(field) in the group by. else you will get an error like... _expression_ not
a grouped _expression_.... or something real helpful like that..
(sarcasm)
Enjoy,
-MEB
Girish do you have a real world example of the
proper usage of the group by clause? My book is real weak on this
subject.
A.
----- Original Message -----
Sent: Monday, June 23, 2003 5:00
PM
Subject: RE: [KCFusion] an easy
one
Looks like what he needs
is
SELECT
DISTINCT... FROM table
name WHERE GROUP BY
Girish
The results should have 1 of each student in a group, ex:
stu1/grpA
stu1/grpB
stu2/grpA
stu2/grpC
I believe the only way to get
only 1 record for each student would be:
SELECT DISTINCT table1.studentID
FROM table1
Keep in
mind that I'm no SQL guru...
Tyson
-----Original
Message----- From: Adaryl Wakefield [mailto:[EMAIL PROTECTED] Sent:
Monday, June 23, 2003 4:14 PM To: [EMAIL PROTECTED] Subject: Re:
[KCFusion] an easy one
Yes ----- Original Message
----- From: <[EMAIL PROTECTED]> To:
<[EMAIL PROTECTED]> Sent: Monday, June 23, 2003 3:56
PM Subject: RE: [KCFusion] an easy one
> Are the studentID
and goalID unique when combined? > > -----Original
Message----- > From: Adaryl Wakefield [mailto:[EMAIL PROTECTED] >
Sent: Monday, June 23, 2003 3:55 PM > To: [EMAIL PROTECTED] >
Subject: Re: [KCFusion] an easy one > > > Tried that still
got a funny record set. Here is a simplifaction of the >
statement > > SELECT DISTINCT table1.studentID,
table2.goalID > FROM table1, table2 > WHERE table1.studentID =
table2.studentID > > I still keep getting multiple tuples for
one studentID > A. > ----- Original Message ----- > From:
<[EMAIL PROTECTED]> > To:
<[EMAIL PROTECTED]> > Sent: Monday, June 23, 2003 3:31
PM > Subject: RE: [KCFusion] an easy one > > > >
SELECT DISTINCT id > > > > -----Original
Message----- > > From: Adaryl Wakefield
[mailto:[EMAIL PROTECTED] > > Sent: Monday, June 23, 2003 3:33
PM > > To: [EMAIL PROTECTED] > > Subject: [KCFusion] an
easy one > > > > > > Its been so long since ive
done this i forgot how. In an sql statement i > > want only unique
values of a field. I tried > > SELECT Unique (id) as id >
> > > but that did not work. > > A. >
> > > > > > > > >
______________________________________________________________________ >
> The KCFusion.org list and website is hosted by Humankind Systems,
Inc. > > List Archives........
http://www.mail-archive.com/[EMAIL PROTECTED] > > Questions,
Comments or Glowing Praise.. mailto:[EMAIL PROTECTED] > > To
Subscribe.................... mailto:[EMAIL PROTECTED] >
> To Unsubscribe................
mailto:[EMAIL PROTECTED] > > > > >
> > >
______________________________________________________________________ >
> The KCFusion.org list and website is hosted by Humankind Systems,
Inc. > > List Archives........
http://www.mail-archive.com/[EMAIL PROTECTED] > > Questions, Comments or Glowing Praise..
mailto:[EMAIL PROTECTED] > > To Subscribe....................
mailto:[EMAIL PROTECTED] > > To
Unsubscribe................ mailto:[EMAIL PROTECTED] >
> > > > > > > >
______________________________________________________________________ >
The KCFusion.org list and website is hosted by Humankind Systems,
Inc. > List Archives........
http://www.mail-archive.com/[EMAIL PROTECTED] > Questions, Comments
or Glowing Praise.. mailto:[EMAIL PROTECTED] > To
Subscribe.................... mailto:[EMAIL PROTECTED] >
To Unsubscribe................
mailto:[EMAIL PROTECTED] > > > >
______________________________________________________________________ >
The KCFusion.org list and website is hosted by Humankind Systems,
Inc. > List Archives........
http://www.mail-archive.com/[EMAIL PROTECTED] > Questions, Comments
or Glowing Praise.. mailto:[EMAIL PROTECTED] > To
Subscribe.................... mailto:[EMAIL PROTECTED] >
To Unsubscribe................
mailto:[EMAIL PROTECTED] > >
______________________________________________________________________ The
KCFusion.org list and website is hosted by Humankind Systems, Inc. List
Archives........
http://www.mail-archive.com/[EMAIL PROTECTED] Questions, Comments or
Glowing Praise.. mailto:[EMAIL PROTECTED] To
Subscribe.................... mailto:[EMAIL PROTECTED] To
Unsubscribe................
mailto:[EMAIL PROTECTED]
______________________________________________________________________ The
KCFusion.org list and website is hosted by Humankind Systems, Inc. List
Archives........
http://www.mail-archive.com/[EMAIL PROTECTED] Questions, Comments or
Glowing Praise.. mailto:[EMAIL PROTECTED] To
Subscribe.................... mailto:[EMAIL PROTECTED] To
Unsubscribe................ mailto:[EMAIL PROTECTED]
|