× 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.



Thanks for giving us the message id. BIG help.
"SQL0122 - Column OHPTTC or expression in SELECT list not valid."
WRKMSGD MSGID(SQL0122) MSGF(QSQLMSG)
5=Display details
1. Display message text
...
-- Column name &1 is specified in the SELECT clause but not in the GROUP
BY clause.
...

Now, let's take your sample
orde rep CODE DATE TIME
123 BOB AAA 072215 090000
123 BOB AAA 072215 093600

Let me doctor it just a wee bit.
orde rep CODE DATE TIME
123 BOB AAA 072315 090000
123 BOB AAA 072215 093600
The reason I doctored it is to show you the problem of using max(date) and
max(time). In this example you can see that the max date is on one row
and the max time is on another. You may need to concatenate them. Let's
say you just want the first row, with the greatest date, and if there are
two times with the same date then check time also, for the same order,
rep, code.
So if I have this data
OTORD# OTUSRN OTTRNC OTTRND OTTRT
123 BOB AAA 20,150,723 90,000
123 BOB AAA 20,150,722 93,600

select otord#, otusrn, ottrnc,
max(ottrnd*1000000 + ottrt) as datetime
from qtemp.temp
group by otord#, otusrn, ottrnc
order by otord#, otusrn, ottrnc

Ends up with
OTORD# OTUSRN OTTRNC DATETIME
123 BOB AAA 20,150,723,090,000

Rob Berendt

As an Amazon Associate we earn from qualifying purchases.

This thread ...

Follow-Ups:
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.