Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8244213
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T21:46:31+00:00 2026-06-07T21:46:31+00:00

I have this example data: Country | Members | Joined USA | 250 |

  • 0

I have this example data:

Country | Members   | Joined
USA     | 250       | 1/1/2012
USA     | 100       | 1/8/2012
Russia  | 75        | 1/20/2012
USA     | 150       | 2/10/2012

When I query this data I would like to aggregate all the records in a given month. The result of the query would look like:

Country | Members   | Joined
USA     | 350       | 1/2012
Russia  | 75        | 1/2012
USA     | 150       | 2/2012

As a select that is simple enough:

select country, count(*) as members , to_char(trunc(joined), 'MM-YYYY')
from table
group by country, to_char(trunc(joined), 'MM-YYYY')

That query will give me data in the format I want, however my issue is that when I go to insert that into a new pivot table I get an error because the to_char() in the select statement is being placed into a DATETIME column (error: ORA-01843 – not a valid month)

When I change the to_char() in the select to to_date() , it still doesn’t work (same error, ORA-01843 – not a valid month):

select country, count(*) as members, to_date(trunc(joined), 'MM-YYYY')
from table
group by country, to_date(trunc(joined), 'MM-YYYY')

Any suggestions on how to modify this query in such a way that I can insert the result into a new table whose “JOINED” column is of type DATETIME?

thanks in advance for any tips/suggestions/comments!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-07T21:46:33+00:00Added an answer on June 7, 2026 at 9:46 pm

    You can do something like to_date('01/'||trunc(joined), 'DD/MM/YYYY'), which would turn it into a valid date first.
    You just need to decide whether to use the first or last day of the month (last is more complicated)

    Another option is to use the EXTRACT function:

     select country, count(*) as members, EXTRACT(MONTH FROM joined) as mn, EXTRACT(YEAR FROM JOINED) as yr,MIN(JOINED) as dt
    from table
    group by country, EXTRACT(MONTH FROM joined), EXTRACT(YEAR FROM JOINED)
    

    and then from that, you could just select the dt column and insert it

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a list within a data frame (in this example, df$candpct ), and
I have a file containing some data (for example, 00927E2B112DB958......). This data is a
For example I have a method that looks like this [self performSelectorOnMainThread:@selector(someMethod) withObject:data waitUntilDone:YES];
I have a multidimensional array with various config settings. Here's an example: $this->data =
I have this example FactoryGirl.define do @site = FactoryGirl.create(:my_site) factory :user do email {
I have this example: public class Inheritance { public static class Animal { public
Suppose we have this example: http://techdroid.kbeanie.com/2009/07/custom-listview-for-android.html with source code available here: http://code.google.com/p/myandroidwidgets/source/browse/trunk/Phonebook/src/com/abeanie/ How can
jquery.ui.position is not taking the margin values when positioning items? I have this example,
I have this URL example.com/photo?people I want to rewrite this URL in the form
I have this simple example I can't seems to get working : MERGE INTO

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.