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



Albino Sousa wrote

>I have this sql:
>
>SELECT cfnum, cfnom, vmmatr, vmser FROM mcli LEFT OUTER joIN VMPNV
>on cfnum = vmcli ORDER BY cfnum
>
>and I get this output on screen
>
> 18   VIATURA CLIENTE           AE9222     144DL
> 18   VIATURA CLIENTE             AE9225     144DL
> 18   VIATURA CLIENTE             AF2891     144L
> 18   VIATURA CLIENTE             AF4645     144DL
> 18   XPTO                      AF4971     144GL
> 18   XPTO                      AF5316     144GL
> 18   TEMP1                       AF5776     144L
>
>Is it possible to obtain the following output?
>
> 18   VIATURA CLIENTE             AE9222     144DL
>                                        AE9225     144DL
>                                  AF2891     144L
>                                  AF4645     144DL
> 23   XPTO                        AF4971     144GL
>                                AF5316     144GL
> 44   TEMP1                       AF5776     144L
>

I think a pure SQL solution would be difficult, but using FETCH INTO should
work in an RPG program.  You'll need to set up your own level break so you
know what to print/display.

You *might* be able to do it in SQL if you UNION the 'header' lines with the
'detail' lines:

SELECT cfnum, cfnom, vmmatr, vmser, '1' FROM mcli LEFT OUTER joIN VMPNV
on cfnum = vmcli UNION
SELECT ' ', ' ' , vmmatr, vmser, '2' FROM mcli LEFT OUTER joIN VMPNV
on cfnum = vmcli
ORDER BY 1,5

If CFNUM is a number, then you will need to select digits(cfnum) in the
first select.

Personally I'd use the FETCH in an RPG program.
  --buck


As an Amazon Associate we earn from qualifying purchases.

This thread ...


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.