|
from: Booth Martin <booth@xxxxxxxxxxxx>
subject: rpg Embedded SQL: date/week order by
As you all can no doubt tell, I am enjoying SQL!
In the category of... it'd be nice to fix if its easy but its not worth
a candle...
I am displaying data in order by date, newest first. Works fine when I
am displaying every day. However when I group by week or month it shows
last year December to June first, then this year February to January
because week 52 is greater than week 1. month 12 is greater than month
1. I can not figure out how to order by date because date is not a
group by field.
Here is the prepared statement I would like to use. It does not
compile. It will compile & run if I order by week, but that gives me
the issue of this thread.
'select'
+ ' Week(Dec((19000000 + XDTE), 8, 0) concat ''000000''),'
+ ' XLOC, XAQT, XORD, XQTY'
+ ' from FILEA'
+ ' join FILEB on XITM = XITM2 and XDTE = XDTE2'
+ ' where XITM = ?'
+ ' group by Week(Dec((19000000 + XDTE), 8, 0)'
+ ' concat ''000000'')'
+ ' order by XDTE desc';
As an Amazon Associate we earn from qualifying purchases.
This mailing list archive is Copyright 1997-2025 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.