Re: GROUP BY query in Oracle

From: <>
Date: Mon, 16 Aug 1999 20:39:53 GMT
Message-ID: <7p9sun$mmd$>

In article <>,   "C. William Grant" <> wrote:
> Zile:
> No problem. What you are really trying to do is to group by the SSN
> the Month portion of the date.
> The query will look something like:
> SELECT ssn, MIN(date_field), MAX(date_field) FROM tbl GROUP BY ssn,
> SUBSTR(TO_CHAR(date_field),1,2)
> This syntax is approximate; I am on the road and away from my doc set
> the moment.
> The other thing you might want to consider is that what you have asked
> for only works
> for a single year. The minute you cross year boundries, grouping by
> month part no
> longer gives you what you want. I would be temped to use the year and
> the month:
> SELECT ssn, MIN(date_field),MAX(date_field) FROM tbl GROUP BY ssn,
> TO_CHAR(date_field,'YYYY-MM')
> Good luck.
> Bill Grant
> Nautilus Consulting Group, Inc.
> Westlake, Ohio

I'm with Bill on this one...

Sent via
Share what you know. Learn what you don't. Received on Mon Aug 16 1999 - 22:39:53 CEST

Original text of this message