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



Here is another possibility. The CTE at the top would encapsulate your
complex query then in the select use the row_number() olap function to tell
you how many rows are left but to do that you have to order in the opposite
direction your result set is ordered by.

with complex as (
select table_name, table_owner
from qsys2.systables
)

select a.*, row_number() over(order by a.table_name desc)
from complex a
order by a.table_name

On Tue, Jul 28, 2020 at 8:07 AM Maria Lucia Stoppa <mlstoppa@xxxxxxxxx>
wrote:

@Joe
Yes, this is a good solution that I can apply.
Than you

Il giorno mar 28 lug 2020 alle ore 15:05 Joe Pluta <
joepluta@xxxxxxxxxxxxxxxxx> ha scritto:

Here's a very dumb option off the top of my head:

with T1 as (select A, B, ..., Z from ...)
select count(*), '' as A, 0 as B, ..., ' ' as Z from T1
union 0, A, B, ..., Z from T1

The first line creates your CTE. The second line creates a count record
where the first field is the count and all the other fields are blank or
zero, the third line brings in all the records from the CTE but with 0
in the count field.

Short of a temporary table, that's the best I can come up with, and it
doesn't address doing a bunch of other subselects on that data. For
that, I definitely think you need a temporary table.


On 7/28/2020 7:52 AM, Maria Lucia Stoppa wrote:
@Vernon,
I didn't attach any example because it's really complex, but you got it
right.
As you stated, select statements can't return more than one result, so
I
was wondering if it's possible to use a CET to serve multiple selects,
and
it seems it's not.
Yes, the many selects that run have the same from clause and where
clause
(built with host variables as you imagined), that's why I hoped I
missed
some tricks or ways to do things.
Thank you

Il giorno mar 28 lug 2020 alle ore 14:34 Vernon Hamberg <
vhamberg@xxxxxxxxxxxxxxx> ha scritto:

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

Please contact support@xxxxxxxxxxxxxxxxxxxx for any subscription related
questions.

Help support midrange.com by shopping at amazon.com with our affiliate
link: https://amazon.midrange.com



--

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

Please contact support@xxxxxxxxxxxxxxxxxxxx for any subscription related
questions.

Help support midrange.com by shopping at amazon.com with our affiliate
link: https://amazon.midrange.com




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.