Use of DISTINCT in SELECT close
Stanley Roche Busk
maxprog at mac.com
Tue Dec 1 03:48:40 CST 2015
Merci François,
but, Ivan, with 'SELECT a, GROUP_CONCAT(b) FROM c GROUP BY a’ how do you access ‘b' later from the cursor?
In this case ‘b' is a ULongField field and aCursor.ULongField( “b" ).Value causes a nil object exception.
Is there a special command?
Thanks,
Stan
> On Dec 1, 2015, at 8:14 AM, Ivan Smahin <ivan_smahin at paradigmasoft.com> wrote:
>
> Hi Stan,
>
>> On Nov 30, 2015, at 3:03 PM, Stanley Roche Busk <maxprog at mac.com> wrote:
>>
>>
>> Ok, actually ‘a' is a string and ‘b' a record number. I try to get all the different versions of ‘a’. ‘a’ may or may not be different, ‘b’ is always different.
>>
>> SELECT (a), b FROM c GROUP BY a ??? I am not in front of my working dev. computer right now so I can’t try :-(
>>
>> Stan
>>
>>
>
> François Van Lerberghe is absolutely right.
> Actually, you want to group results by "a" column. It means - some single value (based on group of "b" values) for each distinct "a" value.
> You should only decide what aggregation function to apply for each group.
>
> Something like this one:
>
> SELECT a, MIN(b) FROM c GROUP BY a;
>
> Another example - if you want to get a list of "b" values (as single value) for each "a" group:
>
> SELECT a, GROUP_CONCAT(b) FROM c GROUP BY a;
>
> ...
>
>>> On Nov 30, 2015, at 1:38 PM, François Van Lerberghe <frvanlerberghe at gmail.com> wrote:
>>>
>>> Hello Stan,
>>>
>>> You must decide what you do for the b column when there is duplicates on column a : you take the first, the last, …
>>>
>>> If you decide to take the first value, your sql query could be this one : SELECT a, FIRST(b) FROM c GROUP BY a
>>>
>
>
>
> --
> Best regards,
> Ivan Smahin
> Senior Software Engineer
> Paradigma Software, Inc
> Valentina - The Ultra-Fast Database
> http://www.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