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