How to get sum of bugs for particular Mnth and particular Year dynamically?

Hi All,
I've a query related to dynamic date and year :
select bug_id,
category,
count(*) Total_bugs,
SUM(CASE when bug_date >= '10/1/2011' and bug_date <= '10/31/2011' Then 1 else 0 end) OCT_11,
SUM(CASE when bug_date >= '9/1/2011' and bug_date<= '9/30/2011' Then 1 else 0 end) SEP_11,
FROM AA_BUG_TBL
GROUP BY BUG_ID,BUG_CATEGORY
In the above query,Can we write one sum statement to get sum of bugs for a particular month and particular year dynamically?
for ex:2 bugs between 10/1/2011 and 10/31/2011 then 2 under oct_11
5 bugs between 09/01/11 and 09/30/2011 then 5 under sep_11
In this case we need to calculate correct no of days for feb
Thanks,
Mahender.

So...
You need to iterate based on something like the month, quarter, year... Then query on that. I'll use a "WITH" clause to illustrate:
with my_bugs as
    select bug_id
         , bug_date
         , case when to_char ( bug_date, 'QYYYY' ) = '12009' then 1 else 0 end y2009q1_bug
         , case when to_char ( bug_date, 'QYYYY' ) = '22009' then 1 else 0 end y2009q2_bug
         , case when to_char ( bug_date, 'QYYYY' ) = '32009' then 1 else 0 end y2009q3_bug
         , case when to_char ( bug_date, 'QYYYY' ) = '42009' then 1 else 0 end y2009q4_bug
         , case when to_char ( bug_date, 'YYYY' ) = 2009 then 1 else 0 end y2009_bug
         , case when to_char ( bug_date, 'YYYY' ) = 2010 then 1 else 0 end y2010_bug
         , case when to_char ( bug_date, 'YYYY' ) = 2011 then 1 else 0 end y2011_bug
         , case when 1 = 1 then 1 else 0 end is_bug_flag
      from bugs
  select bug_id
       , bug_date
       , sum   ( y2009q1_bug ) over () as total_bugs_2009q1
       , sum   ( y2009q2_bug ) over () as total_bugs_2009q2
       , sum   ( y2009q3_bug ) over () as total_bugs_2009q3
       , sum   ( y2009q4_bug ) over () as total_bugs_2009q4
       , sum   ( y2009_bug   ) over () as total_bugs_2009
       , count (*)             over ( partition by is_bug_flag ) as total_bugs
    from my_bugsI mocked up some data so my results will be drastically different than yours but here are the results:
    BUG_ID BUG_DATE  TOTAL_BUGS_2009Q1 TOTAL_BUGS_2009Q2 TOTAL_BUGS_2009Q3 TOTAL_BUGS_2009Q4 TOTAL_BUGS_2009 TOTAL_BUGS
      2014 10-SEP-10                 0                 0               114              1143         1257         10000
      2015 14-APR-10                 0                 0               114              1143         1257         10000
      2016 30-NOV-09                 0                 0               114              1143         1257         10000
      2017 03-JUN-11                 0                 0               114              1143         1257         10000
      2018 29-DEC-10                 0                 0               114              1143         1257         10000
      2019 12-JAN-11                 0                 0               114              1143         1257         10000
      2020 21-APR-10                 0                 0               114              1143         1257         10000
      2021 12-JAN-11                 0                 0               114              1143         1257         10000
      2022 29-NOV-10                 0                 0               114              1143         1257         10000
      2023 20-JUL-11                 0                 0               114              1143         1257         10000
      2024 04-MAR-11                 0                 0               114              1143         1257         10000

Similar Messages

  • How to get the depreciation areas for an asset in particular period

    Hi frndz,
      how to get the depreciation areas for an asset in a particular period for writeup or manual depreciation method.
    Thanks and regards.
    Harisumanth.Ch

    Try table ANLB, then read ANLC.
    Regards.

  • How to get client side validation for double range and double field in stru

    Hi,
    I have achieved client side validation by using <html:javascript formName=""/>
    All fields shows client side validation but double field and double range field is not shows client side validation but shows server side validation.
    I am using Liferay jboss server.
    Please tell me a way to achieve client side validation for double field and double range.
    Thanks & Regards,
    Brijesh Baser

    I see in the query component there is a QueryListener and a QueryOperationListener. Have you tried letting Jdeveloper create methods for these in some backing bean, and putting in some debug code to see when these methods run? I would think one of them could very well be used to validate the input, somehow; if the input were bad you could just raise an exception and pass your error message, I bet.
    If not...
    I am pretty sure that there is an appendix in the Fusion Developer's Guide for Forms developers turned to Java...you might look at what it says for post query. I know in the 10.1.3.0 equivalent documentation, they gave reference to a method in the ViewObject which fired for each record after a query was run. You could definitely intercept this query return from there. In fact doing something like this may be something like what Frank N. was intending when he mentioned ViewObjects "validation". Not sure though. I am still learning what new features there are in 11g adf/bc.
    Good luck.

  • How to get the AS3 SDK for Facebook Platform and the CS SDK to play nice?

    I tried to combine a very basic Photopshop Panel created with the CS SDK v1.5 and the AS3 Facebook SDK (http://code.google.com/p/facebook-actionscript-api/), but get the following errors when I try to login to Facebook in the Panel.
    Error: Error #3200: Cannot perform operation on closed window.
    at Error$/throwError()
    at flash.display::NativeWindow/get bounds()
    at flash.html::HTMLLoader$/createRootWindow()
    at com.facebook.graph.windows::AbstractWindow/showWindow()[C:\Users\MikeHunt\Work\facebookGr aphApi\desktopAPI\com\facebook\graph\windows\AbstractWindow.as:129]
    at com.facebook.graph.windows::LoginWindow/open()[C:\Users\MikeHunt\Work\facebookGraphApi\de sktopAPI\com\facebook\graph\windows\LoginWindow.as:130]
    at com.facebook.graph::FacebookDesktop/login()[C:\Users\MikeHunt\Work\facebookGraphApi\deskt opAPI\com\facebook\graph\FacebookDesktop.as:514]
    at com.facebook.graph::FacebookDesktop$/login()[C:\Users\MikeHunt\Work\facebookGraphApi\desk topAPI\com\facebook\graph\FacebookDesktop.as:161]
    at Test/login()[~/work/code/flash/Test/src/Test.mxml:133]
    at Test/__loginBtn_click()[~/work/code/flash/Test/src/Test.mxml:200]
    I tried using csxs:CSXSWindowedApplication, mx:WindowedApplication, and mx:Application. All had the same errors.
    Thanks,
    forest

    You download the Extension SDK as .... extension. Go to Help->Check for Updates.
    The Extension SDK is listed there. If you are behind a proxy, then don't forget to configure that in Tools->Preferences.
    Sascha

  • How to get count of rows for a table?

    Hi,
    How to get count of rows for a table and secondly, how can i have access to a particular cell in a table?
    Regards,
    Devashish

    Hi Devashish,
    WdContext.node<Your_node_name>().size() will give you the no: of rows.
    This should be the node that is bound to the table's datasource property.
    WdContext.node<Your_node_name>().get<node_name>ElementAt(index_value); will select the row at that particular index.
    You can access an attribute of a particular row as
    WdContext.node<Your_node_name>().get<node_name>ElementAt(index_value).get<attribute_name>();
    Hope this helps,
    Best Regards,
    Nibu.
    Message was edited by: Nibu Wilson

  • How to get sum for each currency's in ALV Report

    Hi,
    A column has amounts with various currency's.
    May I know how to get sum quantity for each currency in ALV Report?
    Thanks in advance.

    Hi,
    Currency value column should have reference to currency code column.
    Regards,
    Wojciech

  • How to get a organization name for a particular user using API's

    Hi alll,
    How to get a organization name for a particular user using API's

    You need to do something like this:
    SearchCriteria criteria = new SearchCriteria("User Login", "XELSYSADM", SearchCriteria.Operator.EQUAL);
                   UserManager usrService = oimClient.getService(UserManager.class);
                   Set<String> retAttrs = new HashSet<String>();
                   retAttrs.add(UserManagerConstants.AttributeName.USER_ORGANIZATION.getId());
                   List<oracle.iam.identity.usermgmt.vo.User> users = usrService.search(criteria, retAttrs, null);
                   System.out.println("ORG KEY :: " + users.get(0).getAttribute("act_key"));

  • How to get the latest update for the phone?

    hey does anyone know how to get the latest upgrade for my phone? 3230 nokia

    http://www.nokia.co.uk/nokia/0,,58162,00.html
    Gadget
    Remember to mark all correctly answered questions as Solved. A forum is only as great as the sum of its parts, together we will prevail.

  • How to get the last error for while loop?

    How to get the last error for while loop? I just want transfer the last error for while loop, but the program use the shift register shift all error every cycle.

    What do you mean by "get" and "transfer"?
    If the shift register is not what you want, use a plan tunnel instead.
    Typically, programmers are interested in the first, not last, error.
    Can you show us your code so we have a better idea what you are trying to?
    LabVIEW Champion . Do more with less code and in less time .

  • How to get title templates library for CC?

    How to get title templates library for CC?  Do you have to download and install PP 6 to get them?

    Try here Library, title templates, template projects missing: Premiere Pro, After Effects, Encore

  • How to get balance sheet report for profit centers

    hi
    how to get balance sheet report for profit centers, is there any transcation code to get that report or i need to create a report painter report for this

    Hi,
    You can use T. code KE5Z for actual line items.
    More to this you can use program RFBILA10 (Use T. code SE38 and program RFBILA10) for complete blance sheet.
    The transaction is for special purpose ledger but this program RFBILA10 can be used for profit center balance also.
    In selection, you can give ledger name which is generally 8A for profit center ledger.
    Reg

  • I went to add my iPod to another computer and when I did it re-bought all of my music and I would like to know how to get my money back for it?

    I went to add my iPod to another computer and when I did it re-bought all of my music and I would like to know how to get my money back for it?
    anyonr know how I can get my money back????????

    Go to Settings>General>Reset>Erase all content and setting. Then re-setup the iPod with your account/media. To redownload iTunes purchases see:
    Downloading past purchases from the App Store, iBookstore, and iTunes Store

  • How to get 64 bit version for premiere elements 12

    How to get  64-bit version for Premier Elements 12 ? 
    I download from ADMISY site.
    Click on win 64 bit and download it.
    When I try to install ther is a error  this download version is not for 64 bit I have try many times but same result

    Hello
    I have been away some days
    ADMISY is a software partners for Adobe
    I running Win 7 Home Edition
    I have received a card with a code when I bought the program and the I
    download from ADMISY
    Sending serial and installation warning
    PhotoshopElements_12_WWEFDJ.7z
    PhotoshopElements_12_WWEFDJ
    PremiereElements_12_WWEFDJ_win32.7z
    PremiereElements_12_WWEFDJ_win32
    I can not find a 64 bit version of 32-bit or 64-bit version of downloads
    This is information I have
    Best regards
    Erling Magnusson
    2015-02-04 22:33 GMT+01:00 Adobe Forums <[email protected]>:
        How to get 64 bit version for premiere elements 12  created by A.T.
    Romano <https://forums.adobe.com/people/A.T.+Romano> in *Premiere
    Elements* - View the full discussion
    <https://forums.adobe.com/message/7162950#7162950>

  • How to get the version no. for service po?

    Hi,
    How to get the version no. for service po?For material po we are getting the version from EKKO-REVNO but for service po Ekko-revno is blank.
    Regards,
    Rachel.

    Hiee,
    It is not like service PO does not have revision.
    REVNO will only exists for any document if amendment is made after releasing it. If in EKKO for all service PO revision number is blank then test if version management is active for document type
    MM->Purchasing->Version management -> External documents
    Here check for your doc type and purchase org version management is active.
    Regs,
    Appie

  • How to get the owner name for the file in ftp using abap ?

    Hi folks ,
    How to get the owner name for the file in ftp using abap ? please help me very ugernt . I tried with all standard FTP commands
    but doest work out me . Helping in this regard highly appreciated ...
    Thanks and regards,
    Swarupa Vanarchi

    Hi
    dont you  have used the os user while calling the FTP_CONNECT FM?
    Hope you are not talking about the user executing the FTP program.
    Else If you are talking about the FTP file creator then its not related to abap as you can handle it by maintaining the user in file name itself.
    May be i am going too far with if and elses here as your question possesses no  clarity.
    Plz elaborate your requirement  before anybody can help.
    Regards
    sateesh

Maybe you are looking for