• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Ron McLeod
  • paul wheaton
  • Jeanne Boyarsky
Sheriffs:
  • Paul Clapham
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
  • Himai Minh
Bartenders:

SQL Query on Dates and Sum

 
Ranch Hand
Posts: 884
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi all,

Sorry if this isn't the right forum to post, but I guess its the most appropriate one around here. I've to formulate SQL to do a transformation of a table into another.

I've a table like this:


And I'd like to transform it into another table like this:


My main difficulties lies in transforming one (01) date column into 12 individual month columns and then populating the correct columns with the count value.

Any help or suggestions are greatly appreciated. Please accept my apologies if I've posted in the wrong forum.

Thanks!
 
ranger
Posts: 17347
11
Mac IntelliJ IDE Spring
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You are trying to do a crosstab query, which isn't pre-built in function in Oracle.

Look at AskTom which is Thomas Kytes website, and do a query, there are tons of posts about how to do a crosstab query.

Mark
 
Chengwei Lee
Ranch Hand
Posts: 884
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Mark, I didn't know what I'm trying to do is known as a crosstab query. Thanks for your help!
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic