Support for LAST() function

Posted by Admin on 27-May-2008 13:27

Hi,

I am new to using Open Edge (actually progress 9.1E) and I had a general question. Does Progress support the aggregate function LAST()? I need to be able to return the last record in a grouping and thought that would work perfectly but every time I use it, I get a syntax error.

Thanks,

Andy

All Replies

Posted by Admin on 27-May-2008 13:32

Posted by Thomas Mercer-Hursh on 28-May-2008 11:53

For the record, LAST is a valid function, although I used LAST-OF a lot more. You might want to post the FOR EACH code and the LAST code and the error and we can tell you what is wrong.

And, the next time you might want to post this in the ABL forum since this forum is supposed to be for sharing good code examples.

Posted by Admin on 29-May-2008 10:00

Apologies if this is the incorrect forum. The forum description stated "ask questions". So, I thought a code related question was appropriate. Would the general forum be more appropriate?

As for my problem, I should have been a bit more clear. I'm using straight SQL over an JDBC (the Progress SQL Explorer Tool) connection. I am not using ABL or 4GL. So, the query is something like this:

select last(pub.phtwt.createdate) as date

from pub.phtwt

where pub.phtwt.sysid = 2

The error I get is:

=== SQL Exception 1 ===

SQLState=42000

ErrorCode=-20003

:Syntax error (7587)

Posted by Thomas Mercer-Hursh on 29-May-2008 11:26

You are right that the description of this forum is less than ideal relative to what I think its purpose is, which is to parallel the Sonic Code Share where people are offering completed solution components for other people to use. Going forward, general questions about ABL are more appropriate here http://www.psdn.com/library/forum.jspa?forumID=28

But, now I read a little farther and see that you aren't even talking about ABL! PSDN doesn't really have a SQL forum per se, so I would tend to post to the OpenEdge General Forum I suppose. Both PEG and ProgressTalk (assuming it comes back on line) have dedicated SQL lists.

AFAIK, Progress SQL-92 has no LAST function. Hence, a syntax error.

Posted by Admin on 02-Jun-2008 20:41

SELECT MAX(CreateDate) AS MaxCreateDate FROM PUB.phtwt WHERE sysid = 2

The MAX function finds the largest value, LAST is a 4gl code element used with the FOR EACH..GROUP BY statements. Database access via ODBC/JDBC can only support SQL statements, not 4gl. There is a pdf file under both the V9 and OE10 documentation set which describes valid SQL syntax.

This thread is closed