× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



You don't have the group by clause (at least you are not showing it here) in your RPG program. Also group by should come before order by.


-----Original Message-----
From: rpg400-l-bounces@xxxxxxxxxxxx [mailto:rpg400-l-bounces@xxxxxxxxxxxx] On Behalf Of Gqcy
Sent: Thursday, May 19, 2011 3:27 PM
To: rpg400-l@xxxxxxxxxxxx
Subject: SQL - group by not working for me.

I have a query I can get to work in STRSQL, but not getting it
to compile in SQLRPGLE...

the premise of the query is to return the latest instance of a user
running a menu option. I have a menu file, and a menu log file.
for every menu file record I retrieve, I want to find the "Latest" time
the user ran that option...


I can't get my SQLRPGLE to accept the GROUP BY, or something else is
wrong!!!

here is my SQL that works in STRSQL:
select mnuprf, mnugrp, mnuopt, mnucmd, mnuonm, max(mts) from
(select mnucmd, mnuprf, mnugrp,
mnuopt, mnuonm, mltimstmp as mts
from pdatalib/menupf
join pdatalib/menulog on mnuprf = mlnuprf and
mnugrp = mlnugrp and
mnuopt = mlnuopt
where mnucmd like ('%ORD500%')
order by mnuprf, mnugrp, mnuopt) as list1
group by mnuprf, mnugrp, mnuopt, mnucmd, mnuonm


here is my RPG that won't compile...
each of the fields in my outer select have a "Column XXXXXX or
expression in SELECT list not valid" (SQL0122)

exec sql declare LOAD cursor for
select mnuprf, mnugrp, mnuopt, mnucmd, mnuonm, max(mts) from

(select mnucmd, mnuprf, mnugrp, mnuopt, mnuonm, mltimstmp as mts
from pdatalib/menupf
join pdatalib/menulog on mnuprf = mlnuprf and
mnugrp = mlnugrp and
mnuopt = mlnuopt
where mnucmd like (:fmtScanVals)
order by mnuprf, mnugrp, mnuopt)
ROWS for fetch only;


Thanks...
--
This is the RPG programming on the IBM i / System i (RPG400-L) mailing list
To post a message email: RPG400-L@xxxxxxxxxxxx
To subscribe, unsubscribe, or change list options,
visit: http://lists.midrange.com/mailman/listinfo/rpg400-l
or email: RPG400-L-request@xxxxxxxxxxxx
Before posting, please take a moment to review the archives
at http://archive.midrange.com/rpg400-l.

________________________________

Notice from Bob Evans Farms, Inc: This e-mail message, including any attachments, may contain confidential information that is intended only for the person or entity to which it is addressed. Any unauthorized review, use, disclosure or distribution is strictly prohibited. If you are not the intended recipient, please contact the sender by reply e-mail and destroy all copies of the original message and any attachments.

As an Amazon Associate we earn from qualifying purchases.

This thread ...

Replies:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.