Quantcast
Channel: SCN: Message List - SAP SQL Anywhere
Viewing all articles
Browse latest Browse all 2182

Re: Show all returns from a query without manually sort, also count returns by value

$
0
0

You might try the Window function count

> count (distinct BlockedOn) over (rows between unbounded preceding and unbounded following)

but at the risk of entering disappointment mode now, I recommend you familiarize yourself with SQL fundamentals first before starting with advanced stuff. You may or may not finally end up with a code snippet that does the job (sometimes / always?) without you knowing why.

I suspect that you're trying to follow an approach that doesn't precisely match the idea of SQL. The Total Count is a scalar aggregation of the whole result set. Why mingle it into each row of the result set when it's always the same value anyway.

The closest thing to basic SQL is to UNION a summary row with the individual rows:

select LastReqTime, BlockedOn, UncommitOps

from sa_conn_info()

WHERE nullif (LastReqTime, '') < DATEADD(mi,-60,GETDATE())

AND BlockedOn > 0 AND UncommitOps = 0

UNION ALL

select NULL, count (distinct BlockedOn), sum (UncommitOps)

from sa_conn_info()

WHERE nullif (LastReqTime, '') < DATEADD(mi,-60,GETDATE())

AND BlockedOn > 0 AND UncommitOps = 0

 

HTH

 

Volker


Viewing all articles
Browse latest Browse all 2182

Latest Images

Trending Articles



Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>