Icon View Thread

The following is the text of the current message along with any replies.
Messages 1 to 3 of 3 total
Thread How to sort a List()?
Mon, Aug 25 2014 12:26 PMPermanent Link

Barry

Often I need to return a sorted list from a table. Often I need unique values in the list.

Select List(Cust_Name) from Customers;

produces an unsorted list.

So does:

Select List(Cust_Name) from (Select Cust_Name from Customers group by Cust_Name) tx

It does not appear the List() can return a sorted list no matter what I do.
Any suggestions?

TIA
Barry
Mon, Aug 25 2014 12:32 PMPermanent Link

Raul

Team Elevate Team Elevate

On 8/25/2014 12:26 PM, Barry wrote:
> Often I need to return a sorted list from a table. Often I need unique values in the list.
>
> Select List(Cust_Name) from Customers;
>
> produces an unsorted list.
>
> So does:
>
> Select List(Cust_Name) from (Select Cust_Name from Customers group by Cust_Name) tx
>
> It does not appear the List() can return a sorted list no matter what I do.
> Any suggestions?

How about SELECT LIST(ORDERED Cust_Name) ...

Raul
Mon, Aug 25 2014 3:28 PMPermanent Link

Barry

Raul wrote:

>How about SELECT LIST(ORDERED Cust_Name) ...<

Yes, that will do it. Smile

I'm using v2.13B2 and the List() "Ordered" option wasn't in the SQL PDF file.  But I see the online documentation has been updated though.

I can also use:

SELECT LIST(ORDERED DISTINCT Cust_Name)  ...

which solves the other problem.

Cool! Thanks.

Barry
Image