|
On 15 Mar 2013 12:40, fbocch2595@xxxxxxx wrote:
SELECT RDDTNM, RDRSET, RDRPTN
FROM REPRD
ORDER BY rddtnm
I get the screen below but how can I remove the duplicate names
and only show one name for every report set? I know it's doable
with WRKQRY but I'd like to use SQL.
The feature is often called outlining, and is a feature of a report
writer, rather than a feature of the retrieval of data, which is all
that the SQL itself does. IIRC the report writer of QMQRY [STRQM,
STRQMQRY with a *QMFORM], which allows SQL statements, provides
outlining for reports as defined in the report form.
DTNM REPORT SET NAME REPORT NAME
ALEX KAPILF ALLITARB4 ALLITARB4
ANDREW LAJR C34TIPPFZ2 C34TIPPFZ2
ANDREW LAJR X12CVMSF X12CVMSF
ANN MCKE P08RATRF P08RATRF
ANN MCKE C36TIPPF C36TIPPF
ANN MCKE D75LEINF D75LEINF
ANN MCKE P88MAILF P88MAILF
ANN MCKE QSYSPRTX QSYSPRTX
ANN MCKE X24RCVMF X24RCVMF
ANN MCKE P09DUPLF P09DUPLF
ANNE MULDEG C01CAXF C01CAXF
ANNE MULDEG C01DETF C01DETF
ANNE MULDEG C03EMPLF C03EMPLF
ANNE MULDEG C12EMPLF C12EMPLF
ANNE MULDEG C17LOSSF C17LOSSF
ANNE MULDEG C23CLEXF C23CLEXF
ANNE MULDEG C23CLSSF C23CLSSF
ANNE MULDEG C25NODTF C25NODTF
ANNE MULDEG C35TIPPF C35TIPPF
The same could be obtained by the SQL, but probably not a preferable
means to achieve that. Here should be one way (untested):
select case when theRowNbr=1 then DTNM
/* else '' */
/* use the "else ''" if blank vs the NULL value [presented as a */
/* dash in the query/400 report writer which is used by STRSQL] */
/* then sort using DESC vs ASC. Note: NULL collates highest */
end
, RptSetName
, RptName
from (select DTNM
, RptSetName
, RptName
, Row_Number()
over(partion by DTNM
/* order by ... no apparent order in the sample */
) as theRowNbr
from theLib/theFile ) as S
order by DTNM ASC, 1 ASC /* <ed: correction made to ORDER BY!> */
As an Amazon Associate we earn from qualifying purchases.
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.