SQL: distinct on single field

Heinrich Ruoff heinrichruoff at gmail.com
Wed Mar 22 23:43:54 CST 2006


Thanks Igor this seems to be working!

Is it normal that in the result cursor the fields formerly named id now are
"No Name2" and Color now is "No Name 3"?

grz
Heinrich


On 3/22/06, Ivan Smahin <ivan_smahin at valentina-db.com> wrote:
>
> Hello Heinrich,
>
> Wednesday, March 22, 2006, 12:02:31 PM, you wrote:
>
> > Hi Igor,
>
> > doesn't seem to work in my application.
> > When I test the simple example in Valentina Studio
> > I get the error:
> > "In the SELECT clause you can use only fields listed in the GROUP BY and
> > aggregative functions."
>
> Sorry, It was too quick.
>
> You could do following:
>
> SELECT ProductCode, Min(Color), Min(id) FROM Products Group By ProductCode
>
> Example:
> ProductCode         Color       ...
> -----------         ------
> 1                   2
> 1                   3
> 1                   4
> ...
>
> Just  you  want  to  choose  single ProductCode value. Then you should
> point  in some way which row should be chosen. So you have to use some
> aggregative function - min, max, sum...
>
>
>
> --
> Best regards,
> Ivan                            mailto:ivan_smahin at valentina-db.com
>
> _______________________________________________
> Valentina mailing list
> Valentina at lists.macserve.net
> http://lists.macserve.net/mailman/listinfo/valentina
>


More information about the Valentina mailing list