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



What you are looking for is an "aggregate" function. This is a function
takes a set of values (like a column of data) and returns a single value
result from the set of values. Sample aggregate functions include COUNT,
SUM, AVG, etc. They are documented at:
http://pic.dhe.ibm.com/infocenter/iseries/v7r1m0/topic/db2/rbafzch2func.htm

The important thing to remember is you cannot include detail columns along
with aggregate functions. For example on your sample
SELECT odobnm, odldat, odltim
FROM myfile
where odldat = 090713 or odldat = 090813
order by odldat
You could only put
SELECT count(odobnm) as NbrObjects
FROM myfile
where odldat = 090713 or odldat = 090813

The exception to the detail column rule is for "control break" columns.
Control breaks are done in SQL by using the "group by" clause. If you
wanted a count, by date, for each date in your range you could do:
SELECT odldat, count(odobnm) as NbrObjects
FROM myfile
where odldat = 090713 or odldat = 090813
order by odldat
group by odldat

Sometimes I forget which comes first GROUP BY or ORDER BY. You'll figure
that out. Gotta go.


Rob Berendt

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.