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



On 1/5/2017 2:24 PM, Steinmetz, Paul wrote:
SELECT REMOTE_ADDRESS , JOB_NAME , LOCAL_PORT FROM
QSYS2.NETSTAT_JOB_INFO WHERE LOCAL_PORT = 23 AND JOB_TYPE =
'INTERACTIVE' AND JOB_NAME LIKE '%QPADEV%' GROUP BY REMOTE_ADDRESS,
JOB_NAME , LOCAL_PORT ORDER BY REMOTE_ADDRESS, JOB_NAME , LOCAL_PORT

So... SQL's command line isn't the same thing as a query reporting tool.
It's not intended to give us things like 'list the detail lines and at
the bottom a count of how many there were'. That said, you can wrestle
with SQL to get what you're after.

As David notes, count(*) is the way to get the final total. One way is
to UNION the detail with the total line:

SELECT REMOTE_ADDRESS , JOB_NAME , LOCAL_PORT, '1' as sort, 1 as n
FROM QSYS2.NETSTAT_JOB_INFO
WHERE LOCAL_PORT = 23
AND JOB_TYPE = 'INTERACTIVE'
AND JOB_NAME LIKE '%QPADEV%'
union
select ' ', ' ', 0 , '9', count(*) as n
from qsys2.netstat_job_info
WHERE LOCAL_PORT = 23
AND JOB_TYPE = 'INTERACTIVE'
AND JOB_NAME LIKE '%QPADEV%'
group by 4, 1, 2, 3
order by 4, 1, 2, 3

You could make that a CTE to your final query in order to return only
the 'interesting' columns, but you get the general idea.

Another possibility is ROLLUP:

SELECT REMOTE_ADDRESS , JOB_NAME , LOCAL_PORT, count(*) as n
FROM QSYS2.NETSTAT_JOB_INFO
WHERE LOCAL_PORT = 23
AND JOB_TYPE = 'INTERACTIVE'
AND JOB_NAME LIKE '%QPADEV%'
group by REMOTE_ADDRESS, JOB_NAME, LOCAL_PORT with rollup
order by 1, 2, 3

The rollup doesn't work without the count(*).

Hope this gives you some ideas ti play with.


As an Amazon Associate we earn from qualifying purchases.

This thread ...

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.