List:MySQL on Win32« Previous MessageNext Message »
From:labsy Date:July 16 2004 2:47pm
Subject:select distinct
View as plain text  
Sorry, but this does not work.
Experimenting  I found resolution, huh:

SELECT DISTINCT recipients, Max(ID) AS MAXID
FROM log_table
GROUP BY recipients
ORDER BY MAXID DESC
LIMIT 15 ;

> Try
> 
> SELECT recipients, Max(ID)
> FROM log_table
> GROUP BY recipients
> ORDER BY Max(ID) DESC 
> LIMIT 15
> 
> John Bonnett
> 
>> -----Original Message-----
>> From: labsy@stripped [mailto:labsy@stripped] 
>> Sent: Friday, 16 July 2004 12:28 PM
>> To: win32@stripped
>> Subject: DISTINCT query
>> 
>> 
>> Hello!
>> 
>> could you please help me construct proper mysql query. I spent 8 hours with
>> testing, but no proper results :((
>> 
>> I have a LOG with at least "ID" and "recipient" fields.
>> I want to extract last 15 different recipients.
>> 
>> I tried this:
>> SELECT ID DISTINCT recipients
>> FROM log_table
>> GROUP BY recipients
>> ORDER BY ID DESC 
>> LIMIT 15
>> 
>> But this returns some unknown 15 different recipients, but not 15 last.
>> Could you help me, please?
>> 
>> 
>>   
>> 
>> -- 
>> Regards,
>> Andrej
>> --------------------------------
>> e-mail:         labsy@stripped
>> Tel.:        +386 (0)7 45 210 44
>> GSM :         +386 (0)41 233 335



Thread
select distinctlabsy16 Jul