15,790,267 members
1.00/5 (1 vote)
See more:
```SELECT TO_CHAR(MDATE,'MONTH')MM, COUNT(*) MON
FROM MY_TABLE
WHERE TO_CHAR(MDATE,'RRRR')=:P1_YEAR
GROUP BY TO_CHAR(MDATE,'MONTH')```

What I have tried:

```SELECT TO_CHAR(MDATE,'MONTH')MM, COUNT(*) MON
FROM MY_TABLE
WHERE TO_CHAR(MDATE,'RRRR')=:P1_YEAR
GROUP BY TO_CHAR(MDATE,'MONTH')```
Posted
OriginalGriff 3-Aug-23 0:47am
This is not a good question - we cannot work out from that little what you are trying to do.
Remember that we can't see your screen, access your HDD, or read your mind - we only get exactly what you type to work with - we get no other context for your project.
Imagine this: you go for a drive in the country, but you have a problem with the car. You call the garage, say "it broke" and turn off your phone. How long will you be waiting before the garage arrives with the right bits and tools to fix the car given they don't know what make or model it is, who you are, what happened when it all went wrong, or even where you are?

That's what you've done here. So stop typing as little as possible and try explaining things to people who have no way to access your project!

Use the "Improve question" widget to edit your question and provide better information.

## Solution 1

A bit hard to follow exactly what you want as an output but,

This gives the Number of records for each month in a given year

SQL
```SELECT Month(MDate) as  MM, COUNT(*) MON
FROM My_Table
WHERE year(MDate)= 2023
GROUP BY Month(MDate)```

This gives the number of months that have an least one record in it for a given year

SQL
```SELECT count(distinct Month(MDate)) as  MM
FROM My_Table
WHERE year(MDate)= 2023```

v2