On 08-Aug-2016 11:03 -0500, Steinmetz, Paul wrote:
I'm looking for the syntax to count all records of any date in a
file. Output to a report.
Perhaps some sample data [NULL values included, if relevant] and the
expected output per that data given as input, and then the DDL for the
file(s) whence the data is selected, would elucidate what seems like a
very ambiguous scenario.
And what is meant by a /report/ also needs clarification, minimally
for what /reporting tool/ is being used; typically a question about how
to formulate a SQL query is resolved by presentation of a particular
SELECT statement for which the expected result-set is produced; i.e. the
/reporting/ is usually [client or server] tooling, into which that query
is the input, and often is an entirely separate topic of discussion that
the query itself.
The most simplistic answer for the syntax of such a query, would be
to obtain a count of all rows *irrespective of any date values* in the file:
select count(*) from table-reference
Slightly different, is to provide a count of all non-NULL date values
for a particular date-column:
select count(date_column_name) from table-reference
Slightly different, is to provide a count of all distinct non-NULL
date values for a particular date-column:
select count(DISTINCT date_column_name) from table-reference
Slightly different, is to provide a count of all rows for a
particular date-value of the date-column:
select count(*) from table-reference
where date_column_name = date'… ' /* replace … with date literal */
As an Amazon Associate we earn from qualifying purchases.