Tim Winters wrote:

Hello everyone,

I have the following select statement

SELECT  DISTINCT sessionID, userID, date, time
FROM sti_tracking
WHERE userID = 999

What I want is to have only records with the userID of 99 and where the
sessionID is distinct (meaning only on of each session id).  Neither
sessionID nor userID are keys or unique.

Obviously this isn't working.

Can someone suggest how this should be done?


If I understand you properly, you want only a single line for each of userID 999's sessions, is that right? Is there some specific date and time that you are interested in for that session, for instance, the first? If so, try:


SELECT sessionID, userID, min(date), min(time)
FROM sti_tracking
WHERE userID = 999
GROUP BY userI, sessionID

Even if I misunderstood, you can probably adapt this into what you really want.

Bruce Feist



--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:    http://lists.mysql.com/[EMAIL PROTECTED]



Reply via email to