Select distinct

Ivan Smahin ivan_smahin at paradigmasoft.com
Thu Mar 20 06:06:16 CDT 2008


Hello Mr.,

Thursday, March 20, 2008, 12:55:08 PM, you wrote:

> Hi Ivan,

> (write this one on your beer list, I will find a way ;-))
:) All the beer today is for Ruslan, for health and so on.
Happy birthday to him!

> we solved it this way (thanks to your clarification)

> select ** from tbl_indicators where recid in (select min(recid) from  
> tbl_indicators group by name)

That is exactly what I mean but only note - you can not be sure
"min(recid)" produces column with name "recid" - so it is better to use alias here.

> I was a bit surprised that you can use min(recid) without stating it  
> in the group by clause.
> Can you  explain why this works ?
> Because it is a function (min)?

It is nature of aggregating functions - they produce the single
value for the group of records - always.


-- 
Best regards,
Ivan Smahin 
Senior Software Engineer
Paradigma Software, Inc
Valentina - The Ultra-Fast Database
http://www.valentina-db.com



More information about the Valentina mailing list