How to deal with date?

How can I replace the XXX in the query below to retrieve the number of transactions that happened every month since January 1st 2008 ' to 31-dec-2008' grouped by dept_id?

Select dept_no, count (transation_no)
from the sale
where trans_date XXX
Dept_no group

THX

Hello

homesick1984 wrote:
Thank you all for the quick answer :)

But, I want just the departments including the transactions that happened each month in the year 2008, i.e., if dept_no = 555 a transactions each month in the year 2008, so should I bring it and no.. of these transactions

thnx :)

In this case, use a HAVING clause:

select    dept_no
,        count (transation_no)      AS cnt
from        sales
where        trans_date     >= TO_DATE ( '01-Jan-2008'
                           , 'DD-Mon-YYYY'
                       )
and       trans_date     <  TO_DATE ( '01-Jan-2009'
                           , 'DD-Mon-YYYY'
                       )
group by  dept_no
having       COUNT (DISTINCT TRUNC (trans_date, 'Month')) = 12
;

If it is still not what you want, then after a few examples of data (CREATE TABLE and INSERT statements) and the results desired from these data.
Simplify as much as possible. For example, reduce the interest from 12 to 3 months period.

Tags: Database

Similar Questions

  • How to deal with the change in scope

    Dear,

    No org by enforcement period. Consolidation of the CDA. CDA entry.

    September, a company (X) is thrown into a perimeter (a-frame) and granted in a different consolidation perimeter (part B).

    I need perform the following acts:

    (A) CDA profit & loss of X, from September, must contribute to A scope results until December;

    (B) BAT profits/losses of X in September, October and December, must contribute to the results of scope B until December.

    (Operations under A) and B) can be automated? No idea how to do?

    I don't have a script. I need only a generic description on how you did.

    Thank you very much!

    According to my experience, assuming that you create a new entity for X under parent B, the best thing to do in these situations is to simply manage it via a journal entry.  You will write a day who would keep the CDA P & L (and in our cash flow of CDA case) result of X to the title of parent with equal and opposite impact hitting the new entity of X under B.  You post this journal in Sep, Oct, Nov and dec and continue loading data for a YEAR to X under B.

    However, if you simply drag & drop X under a new parent, I don't know how you deal with it.

    Kind regards
    Jason

  • How to deal with analysis PC Performance & Stability Report

    Yesterday, when I just walked into my Office Xp, an error report in a program called... uh, PC Performance & Stability Report analysis, can possibly be, telling me to correct these errors have shown under its professional service.
    How to deal with him?
    Thank you for your advice it.

    Hello MeriClaybron,

    1. have you installed any show analyzing the program on your computer?

    This problem can be caused due to infection by the Virus. I suggest that you run a virus scan on your computer using Microsoft Safety scanner and check if you have the same problem.

    http://www.Microsoft.com/security/scanner/en-us/default.aspx

  • Apparently, my memory is almost full - no idea how to deal with not having a novice such am - sd card

    Apparently, my memory is almost full - no idea how to deal with not having a novice such am - sd card

    Hi sixty.

    It can also be a good idea to begin to transfer the content from your phone to a PC/Mac to help reduce the storage room.

    It is a process usually easy, just plug the unit to a PC, on the phone screen select MTP mode when it appears.

    Once finished, you just have to access the phone's internal memory and transfer pictures/videos from the DCIM folder.

    Let us know if you need help in this kind of task.

  • How to deal with operating system windows 8.1 and apps on usb device

    Hi, I have a laptop Lenovo G505. Windows 8 64-bit was preinstalled in it. Later, I upgraded to 8.1. Laptop is almost 9 months and still under warranty. Since a few days, built Lenovo solution Center alert this analysis of hardware detected failures in one or more devices. On suggestion of Lenovo, I ran hdtune pro app in my machine and it also detected 3 hard drive errors. As my machine is under warranty, Lenovo is ready to replace my hard drive with a new one. But they say that it is the responsibility of the customer to return the windows 8.1 operating system and install in the new drive and their liability is limited to the replacement of the hard disk only. I am not computer savvy and I request concerned to guide me how to deal with operating system windows 8.1 on external media like USB, DVD, and install in the new drive. I also installed a number of apps and paid games. Therefore, I would like to resume these games also files so that I need not buy again. Assistance in this regard is required.

    Hello Mohan,

    Thanks for posting your query in Microsoft Community Forum.

    I can of course understand the situation and will be happy to help with your query.

    Let me ask you;

    • You have the key product for Windows 8 or 8.1?

    You can create an installation media (DVD/USB) for Windows 8.1 and re-install when you want. However, in order to create an installation media for Windows 8.1, you need the product key. If you don't have the product key for Windows 8.1, you can not create installation media.

    You can create the installation media for Windows 8 by using the product key Windows 8 If you have. In this case, install you Windows 8 first and then go to Windows 8.1 through store.

    As far as your paid apps (purchased by store) are concerned, you should be able to install them as soon as you sign in with the same Microsoft Account where apps were purchased.

    You can see the steps indicated by Ronnie Vernon replied on 24 December2013, re - install paid apps.

    You can follow the steps below to create installation media.

    1. Run the program Windows 8.1 configuration or installation of Windows 8 (depending on the availability of the product key for the specific operating system.
    2. When you are prompted to run or save the file, choose run

    3. When you are prompted to enter a product key, enter the 25-character product key, that you received when you purchased Windows 8.1 (or Windows 8).

    4. When you are prompted to install Windows 8.1 (or Windows 8), select install by creating media and then click Next.

    5. Select the type of media you want to use: either a Flash DRIVE or a DVD.

    To create a USB flash drive

    1. Click on the USB flash drive.

    2. Plug the USB key into a USB port on your PC.

    3. When you are prompted, select the USB key that you want to use, and then click Next.

      If you have files on the USB flash drive, it will remove them.

    To create a DVD

    1. Click on the ISO file , and then select the location where to save the ISO file.

    2. Insert a blank recordable DVD into your DVD drive.

    3. Burn the ISO of the DVD file using Windows disc Image burner, or another program DVD burning.

    Note: Ensure that the USB or DVD key that you use has nothing else stored on it and has a sufficient free space to download the Windows 8.1 Installer: about 2.3 GB for the 64-bit version.

    You can also read the article below to create a USB stick recovery.

    Create a recovery USB disk

    Hope this information is useful. Please feel free to answer in the case where you are facing in the future other problems with Windows.

    Thank you.

  • After the recent update on 06/01/2016, pdf files created on the Tamil language there are blank pages. How to deal with all this?

    After updated recent Acrobat reader, dated 06/01/2016, files already created with Tamil fonts show blank pages. How to deal with all this?

    Hi tnrk64,

    We just released Acrobat Reader for iOS version 15.4 on 23 January 2016.

    This version includes the special snag you have met.

    Would you please try it and let us know if it works for you?

    If you have problems with Acrobat Reader on the Apple App Store update, please take a look at the following page for advice: http://adobe.com/go/updatehelp

    Thank you!

  • How to deal with the table still growing?

    All tables are more and more applications. In some applications, tables become quickly more and more wide. How to deal with this problem?
    Currently I develop an application system. Should I add a large number of orders to remove the code for each table?

    The problem is delete is very time consuming.

  • regexp: how to deal with different date formats?

    the date comes as varchar2 with '-'and':' as separators for day part and part time respectively. but it may come with different formats such as

    1993-05-17
    1993-05-17 13:04:23
    1993-05-17 13:04
    1993-05-17 13:4
    1993-05-17 13:04
    1993-05-17 13:4:2
    1993-5-17-13:4:2
    1993-5-7-13:4:2

    and so on. date of final format should be ' YYYY-MM-DD HH24-SS'. is it possible to have an intelligent way to deal with different formats of date with separators above and convert the final using regexp format, so that it is compact and universal as possible with assumptions/examples above?

    Thank you

    As others have said, the smartest way is to keep your input in a format method and store your data in a date column.
    But is a simple way to deal with this mess, without regexp,

    with test as (
    select '1993-05-17' d from dual
    union all select '1993-05-17 13:04:23' from dual
    union all select '1993-05-17 13:04' from dual
    union all select '1993-05-17 13:4' from dual
    union all select '1993-05-17 13:4:2' from dual
    union all select '1993-5-17 13:4:2' from dual
    union all select '1993-5-7 13:4:2' from dual
    union all select '1993-05-17 1:4 PM' from dual
    )
    select d
         , to_date( translate( d, 'xampAMP', 'x' )
                  , 'yyyy-mm-dd hh24:mi:ss'
                  )
         + case when instr( upper( d ), 'P' ) > 0 then 0.5 else 0 end cd
    from test
    
  • Help: How to deal with the character of the line following in utl_file.put_line?

    Hello

    We try to generate a flat file from an Oracle table through utl_file.put_line. He is troubled with the Fed line of character. How deal with him or another way to do this?

    Any suggestions are greatly appreciated.

    Thank you.
    Jimmy

    I assume that your database is running on unix/linux?

    Try to use UTL_FILE. PUT (Data), followed by a UTL_FILE. PUT (CHR (13): 10;)

  • How to deal with late payments for creative cloud

    My payment does not pass and I deal with once again, since there is only a technical problem with my card provider. What should I do (Adobe mail indicates only the change payment method, which I'm not interested)

    Thank you

    G

    Hi Melissa,

    Please, contact support by chat/call in order to get corrected billing queries.

    Contact the customer service

    * Be sure that you are connected to your Adobe account while accessing the link *.

    Kind regards

    Sheena

  • Re-setup of PC, how to deal with the installation of cloud

    Hi, I need to re - install my Lenovo WS (WIN8.1). At the time of avant-nuage, I had simply disable my Adobe software and reactivate after installation of operating system. How it works with my apps of cloud? What is the process today?

    Given that it is more or less a common problem that I was looking for a database of standard support entry, but I was not able to find something to help.

    Thank you

    Sven

    It is easier.  You can disconnect before wiping your pc, but you don't need to.  with cc, you can even log out of the old 'dead' computers using a new computer.

    Just do whatever you need to do and when you are ready to install cc, start downloading an app of cc (after signing with your adobe of subscriber id) and will install the desktop application, https://creative.adobe.com/

  • How to clear a session will deal with data manager form.

    Hi all

    I have a form handler, which is an element of extended session. On the page of jsp form, I have two fields (in sections) that refers to the same property in the form Manager.

    The data fields are as shown below

    In section 1 - customerName

    In section 2 - customerName

    If I enter data for customerName section1 and submits the form.

    After you have submitted data, if I go back to the same page, the customerName in both sections fields are filled with the data I entered previously. I do not want the data to appear when I return to the page of the form. How to clear the contents of the form Manager.

    Kind regards

    Yousuf.

    Why do you want to use scope of session for formhandlers? its not recommended.

    But if you want to reset all the fields, and then override the beforeGet() method in formhandler and defined all NULL values.

    Peace

    Shaik

  • How to deal with the JPEG image data

    I have a XML element defined by the user who provides a JPEG image.

    Is it possible to directly use this JPEG information in my PDF? (would be great - but seems to want)

    or I (seems more likley to me) should first write the JPEG data to a file and then load into my PDF file.

    If you can point me to a pretty good example of how to do this, however, it is accomplished, or can explain it in this forum

    I should be grateful if you would, and I think that others might be out a lot as well.

    Thank you

    See you soon

    For XFA-based PDF files, you can simply read the XFA specification to learn how to integrate the JPEG data in this grammar.  But it's easy enough...

  • Problem in dealing with date

    Hello

    I use oracle 11g R2 xe.
    I have a weird case. I have about 30 folders created on 08/01/2012

    When I type this:
    "Select * from TABLE where calling_date = January 8, 2012"
    I have only 9 entries.
    But,
    If I type:
    "Select * from TABLE where calling_date > 7 January 2012"
    I get 30 reviews who created 08/01/2012

    What could be the problem...?

    I use this trigger to insert the value from the date of the call

    CREATE OR REPLACE TRIGGER "BI_Create_CRM".
    BEFORE INSERT OR UPDATE ON CRM
    FOR EACH LINE
    Start
    If (insert) and then
    Start
    : new.calling_date: = sysdate;
    end;
    end if;
    end;

    Kind regards
    Fateh

    Fateh says:
    Hello

    I use oracle 11g R2 xe.
    I have a weird case. I have about 30 folders created on 08/01/2012

    When I type this:
    "Select * from TABLE where calling_date = January 8, 2012"
    I have only 9 entries.
    But,
    If I type:
    "Select * from TABLE where calling_date > 7 January 2012"
    I get 30 reviews who created 08/01/2012

    What could be the problem...?

    I use this trigger to insert the value from the date of the call

    CREATE OR REPLACE TRIGGER "BI_Create_CRM".
    BEFORE INSERT OR UPDATE ON CRM
    FOR EACH LINE
    Start
    If (insert) and then
    Start
    : new.calling_date: = sysdate;
    end;
    end if;
    end;

    Kind regards
    Fateh

    It's just that you totally ignored the part time. A date data type has the time associated with it. You can see that.

    SQL> alter session set nls_date_format = 'DD-MON-YYYY HH24:MI:SS'
      2  /
    
    Session altered.
    
    SQL> select sysdate from dual
      2  /
    
    SYSDATE
    --------------------
    10-JAN-2012 08:39:45
    

    "Select * from TABLE where calling_date > 7 January 2012"

    This very incorrect way of writing a query. Here you have treated the date as a string. So, this will cause conversion implisit.

    How it should be wirttern is.

    select * from table where trunc(calling_date) = to_date('01-07-2012','dd-mm-yyyy')
    

    Yet this will not consider the index (if any) in the calling_date column. So what can we do?

    You can do instead.

    select * from table where calling_date between to_date('01-07-2012','dd-mm-yyyy') and to_date('01-08-2012','dd-mm-yyyy') - interval '1' second
    
  • How to deal with information coming from the disk utility - repair?

    I managed courses of recovery of disk space in my SSD. However, I don't know what to do about this:

    After recovering in the SSD space, I ran the option in DiskUtility 'fix' with these results:

    1 volume bitmap needs minor repairs for orphan blocks

    2 save file system exit code is 8

    3 operation was successful.

    I ran it again, the function of repair with these results:

    1 Macintosh volume has been found damaged and must be repaired

    2 save file system exit code is 8

    3 operation was successful.

    Hoping that the repair function had solved the problem, I ran it again with these results:

    1 volume bitmap needs minor repairs for orphan blocks

    2 save file system exit code is 8

    3 operation was successful.

    Thought that I needed to restart the device. After the re - start disk repair utility told me:

    1 volume bitmap needs minor repairs for orphan blocks

    Invalid 2 free block count

    (it should be 33309635 instead of 333008871)

    3 save file system exit code is 8

    3 operation was successful.

    What is my next step?

    Should I ignore this message?

    If this isn't the case, it must be repaired, and how do I do this?

    Is this something that would need to get a new drive?

    Thank you

    If you don't have a good backup make one now. Always keep your Mac backed up on an external drive with Time Machine or utility of cloning like SuperDuperordouble clone.

    Next step is to clear and re - format the hard drive and then restore your system from now the command option + R keys

    OS X: on OS X Recovery - Apple Support

Maybe you are looking for