2

Is there a way that I can get the smallest date value without SORT and DESC, through SELECT only?

Simon Kissane
  • 4,373
  • 3
  • 34
  • 59
aisha
  • 87
  • 7

2 Answers2

2

Using Unidata 6.1, I would use:

:SELECT BY <DATE_FIELD>

that would sort the keys by the lowest date value. Then you would have to use the first value in the select list.

I'm not sure if that answers your question.

Tim the Enchanter
  • 10,837
  • 4
  • 21
  • 20
  • 1
    Pretty much and thank you. I also learned that to get just the smallest value (date, in my case) I would be using SAMPLE 1. This will only return me the first value when using (order) SAMPLE 1 BY – aisha Feb 15 '21 at 16:35
  • Good point, I hadn't thought of using SAMPLE. – Tim the Enchanter Feb 19 '21 at 23:02
2

In the spirit of "There is more than one way to do it.", you can also use the MAX function with the UniVerse SQL Select syntax. This also works better than using BY because it works with MultiValued fields.

SELECT MIN(DateField) FROM File;

Here is multivalued example from the HS.SALES demo account on my system. The CUSTOMER file has a multivalued fields called BUY_DATE that is in the ORDERS association. You can find the newest date in that field this way.

>SELECT MIN(BUY_DATE) FROM CUSTOMER_ORDERS;
MIN ( BUY_DATE )

        01/07/91

1 records listed.
>     
Van Amburg
  • 1,207
  • 9
  • 15