How can I calculate the count of each row and they are grouped in each mth?

hi, I need help on a database question. How can I count the number of record grouped by the last 12 months? I don't know any way to iterate the month one by one so that it return a table like this:
table_item
id item
1 A
2 B
3 C
4 D
table_record
item date
A 2006-01-01
A 2006-01-01
A 2006-01-01
B 2006-02-01
A 2006-03-01
C 2006-04-01
A 2006-04-01
D 2006-05-01
A 2006-05-01
A 2006-12-01
and I need a query to output following table:
item_count_in_2006
item 06-01 06-02 06-03 06-04 06-05 06-06 06-07 06-08 06-09 06-10 06-11 06-12
A 3 1 1
B 1
C 1
D 1
I tried so many way to do it.. I think SQL can't even product a table like that. Please give me some comments.
Thanks!

select c1,
       count(decode(to_char(c2,'YYYYMM'),'200601',1)) "200601",
       count(decode(to_char(c2,'YYYYMM'),'200602',1)) "200602",
       count(decode(to_char(c2,'YYYYMM'),'200603',1)) "200603",
       count(decode(to_char(c2,'YYYYMM'),'200604',1)) "200604",
       count(decode(to_char(c2,'YYYYMM'),'200605',1)) "200605",
       count(decode(to_char(c2,'YYYYMM'),'200606',1)) "200606",
       count(decode(to_char(c2,'YYYYMM'),'200607',1)) "200607",
       count(decode(to_char(c2,'YYYYMM'),'200608',1)) "200608",
       count(decode(to_char(c2,'YYYYMM'),'200608',1)) "200609",
       count(decode(to_char(c2,'YYYYMM'),'200610',1)) "200610",
       count(decode(to_char(c2,'YYYYMM'),'200611',1)) "200611",
       count(decode(to_char(c2,'YYYYMM'),'200612',1)) "200612"
from   tbl
group by c1
C     200601     200602     200603     200604     200605     200606     200607     200608     200609     200610 
D          0          0          0          0          1          0          0          0          0          0          0          0
A          3          0          1          1          1          0          0          0          0          0          0          1
B          0          1          0          0          0          0          0          0          0          0          0          0
C          0          0          0          1          0          0          0          0          0          0          0          0Nicolas.

Similar Messages

  • Hi, how can i break the value for a row and column once i have converted the image to the array?????​??

    Hi, I would like to know how can i break the value for a row and column once i have converted the image to the array. I wanted to make some modification on the element of the array at a certain position. how can i do that?
    At the moment (as per attachhment), the value of the new row and column will be inserted by the user. But now, I want to do some coding that will automatically insert the new value of the row and the column ( I will use the formula node for the programming). But the question now, I don't know how to split the row and the column. Is it the value of i in the 'for loop'? I've  tried to link the 'i' to the input of the 'replace subset array icon' , but i'm unable to do it as i got some error.
    Please help me!
    For your information, I'm using LABView 7.0.

    Hi,
    Thanks for your reply.Sorry for the confusion.
    I manage to change the array element by changing the row and column value. But, what i want is to allow the program to change the array element at a specified row and column value, where the new value is generated automatically by the program.
    Atatched is the diagram. I've detailed out the program . you may refer to the comments in the formula node. There are 2 arrays going into the loop. If a >3, then the program will switch to b, where if b =0, then the program will check on the value of the next element which is in the same row with b but in the next column. But if b =45, another set of checking will be done at a dufferent value of row and column.
    I hope that I have made the problem clear. Sorry if it is still confusing.
    Hope you can help me. Thank you!!!!
    Attachments:
    arrayrowncolumn2.JPG ‏64 KB

  • How can I get the keyboard commands to do what they are spozed to do?

    Some keyboard commands work OK. But some do unexpected things. For example, when I press the F11 key in InDesign, the page parts like a curtain opening leaving the empty desktop; the same key toggles the page back again. What the F11 key should do is open the Paragraph Style palette. Strangely, the "single-digit" commands -- F5, F6, etc. work OK. But those with 2 digits -- F11, F12 -- do not. (This is a G5 iMac with the original keyboard.) How can I fix this?
    iMac G5 Mac OS X (10.4)

    That's Apple's Exposé at work. To change the keys for that, go into System Preferences, then Dashbord & Exposé (top row, second in). You can change the keys, disable it, or assign corners of the screen to do it.
    Conversely, you could go into InDesign -> Edit -> Keyboard Shortcuts and change the Paragraph style pallete (gotta dig for that) command to Command f-keys.
    I'd actually do the second one, as easy access to Exposé just rules - once you get used to it, it will be second nature. It's especially helpful when you have a pile of Photoshop and InDesign windows open, and need to find one particular one, or need to see something on the desktop.

  • How can I calculate the request time ?

    Hello,
    How can I calculate the total consume time in each request ?
    For example, I want to start calculating the time when I click on a Link or a button and the end time when it completed load the page !
    Eric

    You could use a filter like this one:
    import java.io.*;
    import java.net.*;
    import java.util.*;
    import java.text.*;
    import javax.servlet.*;
    import javax.servlet.http.*;
    import javax.servlet.Filter;
    import javax.servlet.FilterChain;
    import javax.servlet.FilterConfig;
    import javax.servlet.ServletContext;
    import javax.servlet.ServletException;
    import javax.servlet.ServletRequest;
    import javax.servlet.ServletResponse;
    public class TimeFilter implements Filter {
        // The filter configuration object we are associated with.  If
        // this value is null, this filter instance is not currently
        // configured.
        private FilterConfig filterConfig = null;
        private static final boolean debug = false;
        private long start = 0;
        private long end = 0;
        public TimeFilter() {
        private void doBeforeProcessing(ServletRequest request, ServletResponse response)
        throws IOException, ServletException {
            if (debug) log("CalendarFilter:DoBeforeProcessing");
            System.out.print("In Filter  ");
            this.start = System.currentTimeMillis();
            System.out.println((new java.util.Date()).toString() +
                               " start request ");
        private void doAfterProcessing(ServletRequest request, ServletResponse response)
        throws IOException, ServletException {
            if (debug) log("TimeFilter:DoAfterProcessing");
            System.out.println("Completion Time = " + (System.currentTimeMillis() - start));
         * @param request The servlet request we are processing
         * @param result The servlet response we are creating
         * @param chain The filter chain we are processing
         * @exception IOException if an input/output error occurs
         * @exception ServletException if a servlet error occurs
        public void doFilter(ServletRequest request, ServletResponse response,
        FilterChain chain)
        throws IOException, ServletException {
            if (debug) log("TimeFilter:doFilter()");
            doBeforeProcessing(request, response);
            Throwable problem = null;
            try {
                chain.doFilter(request, response);
            catch(Throwable t) {
                problem = t;
                t.printStackTrace();
            doAfterProcessing(request, response);
            // If there was a problem, we want to rethrow it if it is
            // a known type, otherwise log it.
            if (problem != null) {
                if (problem instanceof ServletException) throw (ServletException)problem;
                if (problem instanceof IOException) throw (IOException)problem;
                sendProcessingError(problem, response);
         * Return the filter configuration object for this filter.
        public FilterConfig getFilterConfig() {
            return (this.filterConfig);
         * Set the filter configuration object for this filter.
         * @param filterConfig The filter configuration object
        public void setFilterConfig(FilterConfig filterConfig) {
            this.filterConfig = filterConfig;
         * Destroy method for this filter
        public void destroy() {
         * Init method for this filter
        public void init(FilterConfig filterConfig) {
            this.filterConfig = filterConfig;
            if (filterConfig != null) {
                if (debug) {
                    log("TimeFilter:Initializing filter");
         * Return a String representation of this object.
        public String toString() {
            if (filterConfig == null) return ("TimeFilter()");
            StringBuffer sb = new StringBuffer("TimeFilter(");
            sb.append(filterConfig);
            sb.append(")");
            return (sb.toString());
        private void sendProcessingError(Throwable t, ServletResponse response) {
            String stackTrace = getStackTrace(t);
            if(stackTrace != null && !stackTrace.equals("")) {
                try {
                    response.setContentType("text/html");
                    PrintStream ps = new PrintStream(response.getOutputStream());
                    PrintWriter pw = new PrintWriter(ps);
                    pw.print("<html>\n<head>\n</head>\n<body>\n"); //NOI18N
                    // PENDING! Localize this for next official release
                    pw.print("<h1>The resource did not process correctly</h1>\n<pre>\n");
                    pw.print(stackTrace);
                    pw.print("</pre></body>\n</html>"); //NOI18N
                    pw.close();
                    ps.close();
                    response.getOutputStream().close();;
                catch(Exception ex){ }
            else {
                try {
                    PrintStream ps = new PrintStream(response.getOutputStream());
                    t.printStackTrace(ps);
                    ps.close();
                    response.getOutputStream().close();;
                catch(Exception ex){ }
        public static String getStackTrace(Throwable t) {
            String stackTrace = null;
            try {
                StringWriter sw = new StringWriter();
                PrintWriter pw = new PrintWriter(sw);
                t.printStackTrace(pw);
                pw.close();
                sw.close();
                stackTrace = sw.getBuffer().toString();
            catch(Exception ex) {}
            return stackTrace;
        public void log(String msg) {
            filterConfig.getServletContext().log(msg);
    }and in the web.xml :
       <filter>
            <filter-name>TimeFilter</filter-name>
            <filter-class>
                com.filter.TimeFilter
            </filter>
        <filter-mapping>
            <filter-name>TimeFilter</filter-name>
            <url-pattern>/services/*</url-pattern>
        </filter-mapping > 

  • I have two apple id's because my hotmail account is no longer active. How can I delete the old one and use or update the new one?  Every time I try it won't allow me and now my iPad thinks there are two accounts and they are arguing with each other. Help!

    I have two apple id's because my hotmail account is no longer active. How can I delete the old one and use or update the new one?  Every time I try it won't allow me and now my iPad thinks there are two accounts and they are arguing with each other. Help!

    You can't merge accounts or copy content to a different account, so anything that you bought or downloaded via the old account is tied to that account - so any updates that those apps get you will only be able to download via that account. You can change which account is logged in on the iPad via Settings > Store

  • How can I get the photos on my pc onto my Macbook without emailing each one individually to myself?

    How can I get the photos on my pc onto my Macbook without emailing each one individually to myself?

    Welcome to Apple Support Communities.
    Copy them from your PC to a flash drive or an external drive, then open iPhoto and select Import to Library.
    Depending on your settings, iPhoto might open automatically and ask if you want to import them when the device (camera or flash drive or external drive) containing the images is connected.
    At the end of the import, iPhoto will ask if you want to delete or keep the photos on the other device. Keep until you're absolutely certain all images are imported correctly and you've viewed them in iPhoto. It's always nice to have a backup.

  • How can i calculate the average in java

    how can i calculate the avergae mark out of two marks for instance in like exam mark out
    of two other ones
    thanks for considering this message

    Average or Mean:
    sum_of_N/N
    Here N is the number of marks.
    sum_of_N is the total sum of n(all marks added together)
    public int average(int[] marks) {
    int sum;
    sum = 0;
    for(int i=0;i < marks.length;i++) {
    sum=marks[i]+sum; // keep adding to the total
    return average = sum/marks.length;
    // warning- using an int here can be a pitfall(we could have a decimal outcome).
    }

  • How can I calculate the waveform integral in a defined time interval?

    Hi:
    I need your help. How can I calculate the waveform integral in a defined time interval? For example: from "0" to "2pi"?!
    Thanks.

    Hello Clecio,
    You might want to try the Integral x(t) VI.  The documentation for this VI notes:
    Performs the discrete integration of the sampled signal X. Integral x(t) calculates a definite integral. The value of the output array at any value x is the area under the curve of the input array between 0 and x.
    You would pass the samples of the waveform that fall between your particular window, then pass 1/number of samples for the d(t) parameter.
    Hope that helps.
    Wendy L
    LabWindows/CVI Developer Newsletter - ni.com/cvinews

  • How can I calculate the total time in java?

    Hello!
    I need to calculate the total time!
    For example I have start time:
              Format formatter1;
              Date date1 = new Date();
              formatter1 = new SimpleDateFormat("hh:mm:ss");
              String startTime = formatter1.format(date1);
              //startTime = "14:20:40";
    And I have finish time:
              Format formatter2;
              Date date2 = new Date();
              formatter2 = new SimpleDateFormat("hh:mm:ss");
              String finishTime = formatter2.format(date2);
              //finishTime = "08:30:55";
    So, after manually calculating, I get total time: "18:10:15"
    How can I calculate the total time in java? (Using formatter1 and formatter2 I suppose)
    What I need is to print "total 18:10:15"
    Thanks!

    800512 wrote:
    I did the following but, I think something is wrong here:
    I defined before: Date date1 = new Date(); Date date2 = new Date();
    And it should be exactly 5 seconds between them.
    I found delta between date1 and date2:
    Format formatter = new SimpleDateFormat("HH:mm:ss");
              long timeInMilliFromStart = date1.getTime() - date2.getTime() ;
              Date date3 = new Date(timeInMilliFromStart);
              String timeInSecFromStart = formatter.format(date3);
    and I get always
    //timeInSecFromStart = 02:00:05
    But it should be exactly 00:00:05.
    What can be a problem?Because, like I said, a Date measure an instant in time, not a duration. So when you have 5000 ms, and you turn that into a Date, that means 5 sec. after the epoch, which works out to 1/1/1970 00:00:05.000 GMT.
    As I mentioned, if you're not currently in GMT, then you have to set the TZ of the DateFormat to GMT. Right now, it's showing you the time in your TZ. If you included the date in your SimpleDateFormat, you'd see either 1/1/1970 or 12/31/1969, depending on which TZ you're in.
    Bottom line: You're trying to use these classes in a way they're not meant for, and while you can get the results you want for a limited set of inputs if you understand what these classes do and how to work with that, it's a brittle approach and comes with all kinds of caveats.

  • Text on path: How can I calculate the text length?

    Hi
    I have a text on path (spline item). Now I need the length of this text and the length of the spline item.
    I try to calculate the text length using IWaxLine::GetWidth(), but this is always 0.
    - How can I calculate the length of this text?
    - How can I calculate the length of the spline item?
    Thanks
    Hans

    It would be interesting if you could describe the purpose of your "length", but I don't have an answer anyway. Would the bounding box be sufficient?
    Considering that TOP may be combined with arbitrary spline paths, this could become an exercise in higher math. I haven't yet encountered a function that returns the mathematical length of such a spline.
    Otherwise it could be solved if you iterate and sum up the relevant points of the bounding box (ascender, descender, baseline?) of individual glyphs.
    Be warned that the whole TOP looks alien, as if it were a transplant from a different program. Experience also shows that documented and actually used interfaces / commands are completely different animals ...
    Dirk

  • How can I change the counter symbols for the slideshow templates in Muse?

    How can I change the counter symbols for the slideshow templates in Muse? Currently they are obviously normal text characters. So, how can I change them to filled circles, for example?

    Hi Aish,
    Thank you very much. This was very helpful. I am still new to Muse and try to find my way through all the features and possibilities. I like it very much so far.
    Does Muse support ‘liquid” design as well?
    Thank you !
    Best regards,
    Fred

  • How can I reset the arrows to go back and foreward

    The arrows in the upper left hand corner of the screen that lets you go back to the previous screen, and forward to another screen , are gone. How can I restore them?

    Check to see if they are on the right side of the navigation bar
    Back/Forward: buttons missing -- http://kb.mozillazine.org/Corrupt_localstore.rdf
    see more complete answer in https://support.mozilla.com/questions/851574

  • How can I remove the battery from my Iphone and Ipads?

    How can I remove the battery from my iphone and ipad?

    The iPhone and iPad do not have user serviceable batteries. Battery replacement is handled by Apple. Make an appointment at the Genius Bar if battery replacement is required.

  • I recently had to completely restore my laptop, so I lost the music on my itunes. It's still on my iphone, but how can I keep the music I already have and continue to add more music from the newly set up itunes again?

    I recently had to completely restore my laptop, so I lost the music on my itunes. It's still on my iphone, but how can I keep the music I already have and continue to add more music from the newly set up itunes again? Is there actually a way to do this? I can't help but wonder what the stupid icloud is for if my music is still somewhere in the 'cloud' but it's zero help for restoring music when it's lost on a computer....any help even a site that get's around apple would be great!

    It has always been very basic to always maintain a backup copy of your computer.
    Have you failed to do this?
    If so, not good, you can transfer itunes purchases from the iphone to your computer.  File>Devices>Transfer Purchases
    You can also redownload some itunes purchases in some countries:
    Download past purchases - Apple Support

  • My computer broke and i lost all files including ITunes. what happens to all the stuff purchased already. will this appear in itues when i download it agian? how can i save the music on my ipod and transfere it over to the new itunes?

    my computer broke and i lost all files including ITunes. what happens to all the stuff purchased already. will this appear in itues when i download it agian? how can i save the music on my ipod and transfere it over to the new itunes?

    Unfortunely, all movies and songs purchased in iTunes will be lost...you'll have to purchase them again! Any applications you've purchased, you can download again for free.
    Music Rescue is a program you can use to transfer any and all data (music, movies, pictures..) from your iPod to your computer, and iTunes.
    http://www.kennettnet.co.uk/products/musicrescue/

Maybe you are looking for

  • Concurrence with ADF business components

    I need know, how do I do the concurrence control (connection of several users ) on business components

  • VB code not working in all sheets

    Hi, we have one workbbok and it haveing 4 sheets.We written VBA code in the workbook at module level  by useing SAPBEXon refresh.But whenever we refresh workbook VBA code is working for only opend sheet and not working for other sheets.we want VBA co

  • ? New Gen iPod Rebate w/Educational Computer Purchase

    Educational users can buy a new computer and get up to a $179 rebate on an iPod - anyone know if this applies toward the new iPods just announced? (web page seems to point to old ones)

  • UML Modeling: Round Trip Engineering

    Hi! Yesterday I worked through and tested the UML Modeling: Developing Applications tutorial. Everything worked awsome and I managed to complete step in the tutorial. Today, when I started the studio and wanted to play a little more with Round Trip E

  • How to solve having no external sound?

    ---I HAVE TRIED EVERYTHING--- I have an iPhone 5. I updated it last night. Today I was using it, received a call it was working fine. Then I noticed my keyboard sound wasn't making a sound. So, I looked into it and it turned out there is zero externa