SELECT TRUNC(DATO, 'MONTH'), COUNT(*)
FROM KUNDE_LOG_GET_COMPANY
WHERE (KUNDE_NR = 245041)
GROUP BY TRUNC(DATO, 'MONTH')
Main Topics
Browse All TopicsHi all, I have a table that holds log data. It has a date column. What I want to do is to be able to group this data by month (I can do this), but also by year. So I get something like the following
Jan 2006 - 100
Feb 2006 - 120
Mar 2006 - 109
Jan 2007 - 101
Feb 2007 - 111
Mar 2007 - 98
etc.....
I have the following query which does it by month, but doesn't include the grouping by year...
SELECT TO_CHAR(DATO, 'MON'), COUNT(*)
FROM KUNDE_LOG_GET_COMPANY
WHERE (KUNDE_NR = 245041)
GROUP BY (TO_CHAR(DATO, 'MON'))
Would be greatful if you could help me on this.
Thanks
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
SELECT my_month || ' ' || my_year || '-' || my_cnt
FROM (
SELECT
TO_CHAR(DATO, 'MM') my_sort,
TO_CHAR(DATO, 'MON') my_month,
TO_CHAR(DATE, 'YYYY') my_year,
COUNT(*) my_cnt
FROM KUNDE_LOG_GET_COMPANY
WHERE KUNDE_NR = 245041
GROUP BY
TO_CHAR(DATO, 'MM'),
TO_CHAR(DATO, 'MON'),
TO_CHAR(DATE, 'YYYY')
ORDER BY 3,1
);
Business Accounts
Answer for Membership
by: angelIIIPosted on 2007-07-13 at 03:25:19ID: 19479393
SELECT TO_CHAR(DATO, 'MON YYYY'), COUNT(*)
FROM KUNDE_LOG_GET_COMPANY
WHERE (KUNDE_NR = 245041)
GROUP BY (TO_CHAR(DATO, 'MON YYYY'))