Remove the last 35 days of a table data

Hello

I had a table to n days of data. I need to remove the last 35 days of data. My table has consecutive dates i.e. There were no load weekend or holidays...

(1) Using INTERVAL command can simply calculate the difference. So it won't work.

(2) I can use RANK to find the sequence. Is there a better way to write a logic to delete?.

concerning

KVB

PurveshK,

I think you have the right idea. Just get the ID of the innermost query.

This should be quite effective, especially if there is an index on the date.

drop table t;

create table t:

Select trunc (sysdate) - level * 2 double dt connect by level<=>

delete t

where rowid in)

Select rn

de)

Select the rowid rn, dense_rank() over (order by dt desc) dr

t

)

where dr<=>

);

Post edited by: StewAshton:

Furthermore, the date field must be NOT NULL for the index be used - or even add WHERE DATE IS NOT NULL to the innermost query.

Tags: Database

Similar Questions

  • EqualLogic - remove the last member of the Group

    I want to remove the last member of a pool.  Data has been moved to the other pools.  Will I need to use the reset directly related to the table command?  It is also the default pool but I understand that I can not remove the default pool and it's ok.

    Hello

    If there are yet other members of the group, then NO, please do not use "reset".   That is only used when it is the only member of the Group overall.   You always use the option 'remove member '.  Either through the user interface or the CLI.

    Any pool can be designated as the "default".

    Kind regards

    Don

  • Select the last 7 days

    How to select the last 7 days of my table, I use the query, but it is the calculation according to sysdate
    It is the data of my talble
    DP_DATE
    ---------
    03-APR-10
    21-APR-10
    22-APR-10
    23-APR-10
    26-APR-10
    27-APR-10
    28-APR-10
    29-APR-10
    30-APR-10
    03-MAY-10
    04-MAY-10
    
    11 rows selected.
      select distinct dp_date
      from dailyprice
      where trunc(dp_date) between trunc(sysdate-7) and trunc(sysdate)
    
    this query is returning 
    DP_DATE
    ---------
    29-APR-10
    30-APR-10
    03-MAY-10
    04-MAY-10
    I want to choose last 7 days
    APRIL 26, 10
    APRIL 27, 10
    28 APRIL 10
    APRIL 29, 10
    30 APRIL 10
    MAY 3, 10
    4 MAY 10

    kindly Guide

    concerning

    Hello

    Use DENSE_RANK() rather than ROW_NUMBER().

    with mytable
    as
    (
    select 'abcFund' FND , to_date('09-MAY-10','dd-mon-rr') dp_date, 10 price from dual union all
    select 'dddFund', to_date('09-MAY-10','dd-mon-rr'), 12 from dual union all
    select 'abcFund', to_date('09-MAY-10','dd-mon-rr'), 12 from dual union all
    select 'edfFund', to_date('09-MAY-10','dd-mon-rr'), 12 from dual union all
    select 'eeeFund', to_date('09-MAY-10','dd-mon-rr'), 12 from dual union all
    select 'dddFund', to_date('08-MAY-10','dd-mon-rr'), 12 from dual union all
    select 'abcFund', to_date('08-MAY-10','dd-mon-rr'), 12 from dual union all
    select 'edfFund', to_date('08-MAY-10','dd-mon-rr'), 12 from dual union all
    select 'eeeFund', to_date('08-MAY-10','dd-mon-rr'), 12 from dual union all
    select 'eeeFund', to_date('08-MAY-10','dd-mon-rr'), 12 from dual union all
    select 'dddFund', to_date('07-MAY-10','dd-mon-rr'), 12 from dual union all
    select 'abcFund', to_date('07-MAY-10','dd-mon-rr'), 12 from dual union all
    select 'edfFund', to_date('07-MAY-10','dd-mon-rr'), 12 from dual union all
    select 'edfFund', to_date('05-MAY-10','dd-mon-rr'), 11 from dual union all
    select 'dddFund', to_date('05-MAY-10','dd-mon-rr'), 12 from dual union all
    select 'eeeFund', to_date('05-MAY-10','dd-mon-rr'), 12 from dual union all
    select 'dddFund', to_date('04-MAY-10','dd-mon-rr'), 12 from dual union all
    select 'abcFund', to_date('04-MAY-10','dd-mon-rr'), 12 from dual union all
    select 'dddFund', to_date('03-MAY-10','dd-mon-rr'), 12 from dual union all
    select 'abcFund', to_date('03-MAY-10','dd-mon-rr'), 12 from dual union all
    select 'edfFund', to_date('03-MAY-10','dd-mon-rr'), 12 from dual union all
    select 'eeeFund', to_date('03-MAY-10','dd-mon-rr'), 12 from dual union all
    select 'dddFund', to_date('01-MAY-10','dd-mon-rr'), 12 from dual union all
    select 'abcFund', to_date('01-MAY-10','dd-mon-rr'), 12 from dual union all
    select 'abcFund', to_date('30-APR-10','dd-mon-rr'), 11 from dual
    )
    select dp_date
          from ( select dp_date
                      , dense_rank() over (order by dp_date desc) rn
                   from mytable
               )
         where rn <= 7;
    

    Courtesy: Rob SQL
    * 009 *.

    Published by: 009 on May 6, 2010 05:01

  • remove the last record from the plsql table

    TYPE r_LOOPElement IS RECORD (TermID   NUMBER 
                                          );
    
    TYPE t_LOOPType IS TABLE OF r_LOOPElement INDEX BY BINARY_INTEGER;
    i_CustomerLoop      t_LOOPType ;
    
    i_CustomerLoop(1).TermID=1;
    i_CustomerLoop(2).TermID=2;
    i_CustomerLoop(3).TermID=3;
    Under certain conditions, I need to remove the last record from i_CustomerLoop

    whichi s the best way to do it. because I sometimes get duplicates for TermID in this plsql table.

    Hello

    See [removing items from Collection (DELETE method) | http://download.oracle.com/docs/cd/B28359_01/appdev.111/b28370/collections.htm#CJAFGFIG]

    Kind regards

  • Why I have not received e-mails from the last 2 days?

    It seems that my account has been hacked. All my contacts were deleted and some of my emails from my inbox sent have also been removed. Quite simply, I can't receive emails. I tried to use my son's account to see if there is no message, but nothing whatsoever, just, I don't get the emails. What can I do to start getting emails again and maybe even get all my contacts back?

    Send you an email and see if you receive?  If this isn't the case, then there are probably a problem with your account.   If you get it, you may have no emails in the last 2 days (or if you are unsure that you did, just on).  If you use an e-mail program, go to the place on your online account and see if the emails are there - then the problem is that they are not transmitted for some reason any (it could be your e-mail program or it could be the provider - difficult to say at this stage).

    You need to discuss with your email provider (one that provides you with e-mail service - perhaps your ISP, but maybe someone else entirely).  They are the ones who can access these things on your account and understand what is the problem (or help you to fix your computer's settings so that you get emails again).

    I hope this helps.

    Good luck!

    Lorien - MCSA/MCSE/network + / has + - if this post solves your problem, please click the 'Mark as answer' or 'Useful' button at the top of this message. Marking a post as answer, or relatively useful, you help others find the answer more quickly.

  • Receive several codes error over the last seven days. This means - my computer is dead?

    Would like to inform if my computer is really damaged:

    The following errors are produced

    Error 2-32 in the last 7 days

    Error 11-190 in the last 7 days

    Error 14-1 in the last 7 days

    Error 55 7 during the last 7 days

    Error 102-19 over the last 7 days

    Error 1001-36 in the last 7 days

    This means - my computer is dead?

    Thank you

    Original title: Error Messages

    Hello

    They are very good methods for most Windows troubleshooting performance problems.

    Error: Windows Explorer has stopped working
    http://support.Microsoft.com/kb/2694911

    Crashes Windows or freezes<- try="" these="" first="" and="" the="" methods="" do="" apply="" to="" your="">
    http://support.Microsoft.com/kb/2681286#method22

    Performance and Maintenance<- check="" these="" especially="" the="">
    http://Windows.Microsoft.com/en-us/Windows/performance-maintenance-help#performance-maintenance-help=Windows-7&V2H=win7tab1&V3H=winvistatab1

    Other methods of troubleshooting to use according to your needs:

    Use the startup clean and other methods to try to determine the cause of and/or
    eliminate problems.

    ---------------------------------------------------------------

    References to Vista also apply to Windows 7.

    What antivirus/antispyware/security products do you have on the machine? Include
    everything you've ALWAYS had on this machine, including those you have uninstalled (they
    remains of leave behind which can cause strange problems).

    ----------------------------------------------------

    Follow these steps:

    Try these to erase corruption and missing/damaged file system repair or replacement.

    Start - type this in the search box-> find COMMAND at the top and RIGHT CLICK – RUN AS ADMIN

    Enter this at the command prompt - sfc/scannow

    How to fix the system files of Windows 7 with the System File Checker
    http://www.SevenForums.com/tutorials/1538-SFC-SCANNOW-Command-System-File-Checker.html

    How to analyze the log file entries that the Microsoft Windows Resource Checker
    (SFC.exe) program generates in Windows Vista cbs.log
    http://support.Microsoft.com/kb/928228

    Also run CheckDisk, so we cannot exclude as much as possible of the corruption.

    How to run check disk in Windows 7
    http://www.SevenForums.com/tutorials/433-disk-check.html

    ==========================================

    After the foregoing:

    How to troubleshoot a problem by performing a clean boot in Windows
    Vista or Windows 7

    http://support.Microsoft.com/kb/929135

    Use advanced tools to solve performance problems in Windows 7
    http://www.howtogeek.com/HOWTO/6152/use-advanced-tools-to-troubleshoot-performance-problems-in-Windows-7/

    Problems with the overall speed of the system and performance
    http://support.Microsoft.com/default.aspx/GP/slow_windows_performance?p=1

    Optimize Windows 7 for better performance
    http://Windows.Microsoft.com/en-us/Windows7/optimize-Windows-7-for-better-performance

    Open the troubleshooter of Performance
    http://Windows.Microsoft.com/en-us/Windows7/open-the-performance-Troubleshooter

    To see everything that is in charge of startup - wait a few minutes without doing anything-
    then right click on taskbar - task manager - take a look at Applications.
    Process - Services - this is a quick reference (if you have a little box on)
    Lower left - show for all users, then check that).

    How to change, add or remove startup programs in Windows 7
    http://www.SevenForums.com/tutorials/1401-startup-programs-change.html

    Is a quick check to see who are loading method 2 - using MSCONFIG
    then after a list of these here.
    --------------------------------------------------------------------

    Tools that should help you:

    Process Explorer - free - find out what files, registry keys, and other objects
    processes have open, which DLLs they have loaded and more. This unique
    powerful utility will show you even owned by each process.
    http://TechNet.Microsoft.com/en-us/Sysinternals/bb896653.aspx

    Autoruns - free - see what programs are configured to start automatically
    When your system boots and you connect. Autoruns also shows you the complete list
    locations of registry and files where applications can configure start automatic settings.
    http://TechNet.Microsoft.com/en-us/sysinternals/bb963902.aspx
    Process Monitor - Free - monitor file system, registry, process, thread and DLL
    activity in real time.
    http://TechNet.Microsoft.com/en-us/Sysinternals/bb896645.aspx

    There are many excellent free tools from Sysinternals
    http://TechNet.Microsoft.com/en-us/Sysinternals/default.aspx

    WhatsInStartUP - free - this utility displays the list of all applications that are
    loaded automatically when Windows starts. For each application, what follows
    the information is displayed: Type of startup (registry/Startup folder), Command - Line
    Channel file, the product name, Version, company name, location in the registry or
    file system and more. It allows you to easily disable or remove unwanted programs
    that runs in your Windows startup.
    http://www.NirSoft.NET/utils/what_run_in_startup.html

    There are many excellent free tools to NirSoft
    http://www.NirSoft.NET/utils/index.html

    Window Watcher - free - do you know what is running on your computer? Maybe
    not. The window Watcher says it all, every window created by each execution of the statement
    program, if the window is visible or not.
    http://www.KarenWare.com/PowerTools/ptwinwatch.asp
    Many excellent free tools and an excellent newsletter at Karenware
    http://www.KarenWare.com/

    ===========================================

    Think about it an absolute must - manually update your drivers.

    Vista and Windows 7 updated drivers love then here's how update the most important.

    This is my generic how updates of appropriate driver:

    This utility, it is easy see which versions are loaded: run DriverView - set
    SEE drivers to hide Microsoft - update those with Dump in their names. (Also
    updated the BIOS and drivers from the chipset on the site of the constructor/the system motherboard).

    -Free - DriverView utility displays the list of all device drivers currently loaded
    on your system. For each driver in the list, additional useful information is
    Poster: load address of the driver, description, version, product name,.
    company that created the driver and more.
    http://www.NirSoft.NET/utils/DriverView.html

    For drivers, visit Maker as replacements and system manufacturer of device which are
    the most recent. Control Panel - write - graphics card - device manager
    the brand and complete model of your video card - double click - tab of the driver-
    Note the version information. Now click on UPdate Driver (this can do nothing
    MS is far behind the certification of drivers) - then do a right click - Uninstall - REBOOT
    This will refresh the driver stack.

    Repeat this for network - card (NIC), Wifi network, sound, mouse, and keyboard
    If there are 3rd party with their own software and drivers and the other main device drivers
    you have.

    Now, go to the site of the manufacturer of system (Dell, HP, Toshiba as examples) (restore)
    and site (Realtek, Intel, Nvidia, ATI, for example) and get the manufacturer and device
    their latest versions. (Look for the system to update the BIOS, Chipset and software updates
    Site of the manufacturer here.)

    Download - SAVE - go to where you put them - right click - RUN AD ADMIN -.
    REBOOT after each installation.

    Always check in the Device Manager - drivers tab to be sure the version you are
    installation actually appears. This is because that some rollback of drivers before the
    later is installed (particularly that audio drivers) so install a driver - reboot.
    Make sure that it is installed and repeat if necessary.

    Repeat to the manufacturers - BTW to the device makers DO NOT RUN THEIR
    SCANNER - check manually by model.

    Look at the sites of the manufacturer for drivers - and the manufacturer of the device manually.
    http://pcsupport.about.com/od/driverssupport/HT/driverdlmfgr.htm

    Installation and update of drivers under Windows 7 (updated drivers manually using
    the above methods is preferable to ensure the latest drivers from the manufacturer of system
    and device manufacturers are located)
    http://www.SevenForums.com/tutorials/43216-installing-updating-drivers-7-a.html

    If you update the drivers manually, then it's a good idea to disable driver facilities
    in the updates of Windows, which leaves on Windows updates, but it will not be installed
    pilots who are generally older and cause problems. If updates provides a new
    driver then hide it (right click on it) and then go get new ones manually if
    you want.

    How to stop Windows 7 automatically install drivers
    http://support.Microsoft.com/kb/2500967

    ===========================================

    Refer to these discussions because many more excellent advice however remember to check
    your antivirus, the main drivers and BIOS update programs and also to solve problems
    with the first method cleanboot.

    Problems with the overall speed of the system and performance
    http://support.Microsoft.com/GP/slow_windows_performance/en-us

    Performance and Maintenance Tips
    http://social.answers.Microsoft.com/forums/en-us/w7performance/thread/19e5d6c3-BF07-49ac-a2fa-6718c988f125

    Explorer Windows stopped working
    http://social.answers.Microsoft.com/forums/en-us/w7performance/thread/6ab02526-5071-4DCC-895F-d90202bad8b3

    I hope this helps.

    Rob Brown - Microsoft MVP<- profile="" -="" windows="" expert="" -="" consumer="" :="" bicycle=""><- mark="" twain="" said="" it="">

  • How to get the last business day of the previous month?

    Hi all

    We need the user as below,

    If the user select 18 June 2015 ' quick dashboard as the input value, and then they want to see last month last day of work (business date: 29-may-2015) amount in report, if you have an idea please share with us.thanks

    Note:

    use under request we can able to get the last day of the previous month, we want to for the last business day of the last month, based on the date of entry of the user?

    TIMESTAMPADD (SQL_TSI_DAY,-(1), TIMESTAMPADD (SQL_TSI_DAY, DAYOFMONTH ("DIM_TIME". ("" DataDate ") *-(1) + 1,"DIM_TIME ". (("" DataDate "))

    Thank you

    Deva

    Try this,

    case when Dayofweek (timestampadd (sql_tsi_day, Dayofmonth(Date '2015-06-15') *-1, Date ' 2015-06-15')) = 1 then timestampadd (sql_tsi_day, (Dayofmonth(Date '2015-06-15') *-1)-2, Date '' 2015-06-15) when Dayofweek (timestampadd (sql_tsi_day, Dayofmonth(Date '2015-06-15') *-1, Date ' 2015-06-15')) = 7 then timestampadd (sql_tsi_day, Dayofmonth(Date '2015-06-15') *-1-1, Date '' 2015-06-15) another timestampadd (sql_tsi_day, Dayofmonth(Date '2015-06-15') *-1, Date ' 2015-06-15') end

    As Ftsiot said in this post, it will work only to exclude the sat and Sun. Another one if you want to exclude regional holiday, you may need a calendar in DB table.

    Thank you

    AJ

  • How to remove the last session of the user of the SQL backend?

    Sometimes the user session gets closed between some of the work for any reason.

    When the next time that the user logs on P6, he gets an error or special functionaly dosen't work for this user or the system hangs.

    In this case if I decided to clear the history of the last session of this user from the databases, how to write the SQL query?

    I don't want to remove all user sessions in the table USESSION and USESSAUD, I just want to remove the last session of the user to particular user (e.g., XYZ).

    You can consult Re: currently connected users

  • How to identify the last instance of a dynamic table row

    Hi all

    I'm trying to figure out how to create an action for my form in Livecycle Designer ES2, which will affect the last instance of a dynamic table row. I have a table with a repeatable row where the user will enter information about a part purchased and I have buttons that allow the user to add and remove the lines. I need to create a line extra addition button which will add a new instance of the repeatable table line (this is not a problem) and disable and change the background color of the first cell in the row added. The problem I have is how to have an action that affects the last instance of a line.

    If anyone knows how to do this in Javascript, I would appreciate some advice/help.

    Hello

    I think that it is beyond providing an action. You will have a need to write JavaScript directly.  When you call the addInstance method it returns the new line, if you can do something like;

    var line = Table1._Row1.addInstance ();

    line. TextField1.border.fill.color.value = "255,0,0";

    line. TextField1.access = 'protected ';

    To find the last line and do the same thing, you can do something like;

    var line = Table1.resolveNode ("Row1 [" + (Table1._Row1.count - 1) + "" "]" ");

    line. TextField1.border.fill.color.value = "255,0,0";

    line. TextField1.access = 'protected ';

    Concerning

    Bruce

  • To remove the last "/" character

    I need to remove ' / ' character and string comes after him. I'll give an example.

    CREATE TABLE TAB (COL1 VARCHAR2 (50));

    INSERT INTO VALUES TAB ("IHA/SS/TTTT/FFFF');

    INSERT INTO TAB VALUES (' hDFF/AA/S/AAAAAAAA");

    I would remove the last "/" and chain comes after him then when I ask, I should get the result that

    IHA/SS/TTTT
    hDFF/AA/S

    Please help me
    with testdata as (
      select 'hDFF/AA/S/AAAAAAAA' s from dual union all
      select 'hIA/SS/TTTT/FFFF'     from dual
    )
    
    select
     substr( s
            ,1
            ,instr(s, '/', -1) - 1
     ) r
    from testdata        
    
    R
    hDFF/AA/S
    hIA/SS/TTTT
    
  • Last address and previous address in the last 30 days

    People in the morning.

    I need to know to all customers whose address has changed, based on the date of entry into force. The query should be based from the 1st June 12 effective date and not SYSDATE. So, we want to check the MAX (effective_date) is < = 1 June 12 and entry into force of the previous address is between 2 May 12 and June 1, 12 (30 days). This suggests that the address has changed. For the sake of the argument, the postal Code is enough to make the difference that the address has changed for now.


    According to the data, I only take customer 1002 but not 1001, 1003. With respect to the customer ID 1003, although his address has changed in the last 30 days, we aren't interested as the effective address June 1 has been good for a long time.

    In addition, even if the address for the customer ID 1001 changed twice in this period, I'm only interested for the last two addresses.

    Table CUST_ADDRESS
    CREATE TABLE CUST_ADDRESS
      (
        "CUST_NO"  VARCHAR2(4 BYTE) NOT NULL,
        "STREET"   VARCHAR2(20 BYTE),
        "CITY"     VARCHAR2(20 BYTE),
        "STATE"    VARCHAR2(2 BYTE),
        "ZIP_CODE" VARCHAR2(9 BYTE),
        "EFFECTIVE_DATE" DATE
      );
    INSERT the Script
    Insert into CUST_ADDRESS (CUST_NO,STREET,CITY,STATE,ZIP_CODE,EFFECTIVE_DATE) values ('1001','123 Picket Fences','Santa Ana','CA','92704',to_date('31-MAY-12','DD-MON-RR'));
    Insert into CUST_ADDRESS (CUST_NO,STREET,CITY,STATE,ZIP_CODE,EFFECTIVE_DATE) values ('1001','12259 Circular Dr','Irvine','CA','92705',to_date('10-APR-12','DD-MON-RR'));
    Insert into CUST_ADDRESS (CUST_NO,STREET,CITY,STATE,ZIP_CODE,EFFECTIVE_DATE) values ('1001','22 Green Road','Newport Beach','CA','92709',to_date('03-JAN-12','DD-MON-RR'));
    
    Insert into CUST_ADDRESS (CUST_NO,STREET,CITY,STATE,ZIP_CODE,EFFECTIVE_DATE) values ('1002','12 Parkside Dr','Chicago','IL','60601',to_date('20-MAY-12','DD-MON-RR'));
    Insert into CUST_ADDRESS (CUST_NO,STREET,CITY,STATE,ZIP_CODE,EFFECTIVE_DATE) values ('1002','3200 Court Road','Indianapolis','IN','46201',to_date('02-MAY-12','DD-MON-RR'));
    
    Insert into CUST_ADDRESS (CUST_NO,STREET,CITY,STATE,ZIP_CODE,EFFECTIVE_DATE) values ('1003','24 Jaeger St','Bellingham','WA','98225',to_date('01-JUL-12','DD-MON-RR'));
    Insert into CUST_ADDRESS (CUST_NO,STREET,CITY,STATE,ZIP_CODE,EFFECTIVE_DATE) values ('1003','145 NE 38th St','Fort Lauderdale','FL','33334',to_date('18-JUN-12','DD-MON-RR'));
    Insert into CUST_ADDRESS (CUST_NO,STREET,CITY,STATE,ZIP_CODE,EFFECTIVE_DATE) values ('1003','212 Coral Drive','Miami','FL','33010',to_date('01-JAN-95','DD-MON-RR'));
    Thanks to a bouquet.

    Published by: Roxyrollers on July 26, 2012 09:35

    Something like that

    SQL> ed
    Wrote file afiedt.buf
    
      1  select *
      2    from (
      3  select ca.*,
      4         max(effective_date) over (partition by cust_no) max_eff_date,
      5         lag(effective_date) over (partition by cust_no order by effective_date) prior_eff_date
      6    from cust_address ca)
      7   where prior_eff_date between date '2012-05-02' and date '2012-06-01'
      8*    and max_eff_date <= date '2012-06-01'
    SQL> /
    
    CUST STREET               CITY                 ST ZIP_CODE  EFFECTIVE MAX_EFF_D PRIOR_EFF
    ---- -------------------- -------------------- -- --------- --------- --------- ---------
    1002 12 Parkside Dr       Chicago              IL 60601     20-MAY-12 20-MAY-12 02-MAY-12
    

    Justin

  • How to select the last 20 transactions in a table

    Hi guys,.
    I have a table named INOUT with following columns

    EMPLOYEECODE VARCHAR2
    DATE OF THE RESPONDENT


    each day employees now their me 'in '. then entered came and came in this table. If we want to select the last 20 EMPLOYEECODE in this table that make their selves 'in '. How to choose that? just 20 last employees who traded. Help, please

    Hello

    This is called a Query Top - N , you want to choose elements of N (N = 20, in this case) from the top of a sorted list.
    Here's a way to do it:

    WITH     got_r_num     AS
    (
         SELECT       emloyeecode
         ,       MAX (intime)     AS latest_intime     -- If wanted
         ,       RANK () OVER (ORDER BY  MAX (intime)  DESC)
                        AS r_num
         FROM       inout
         GROUP BY  employeecode
    )
    SELECT     employeecode
    ,     latest_intime          -- If wanted
    ,     r_num               -- If wanted
    FROM     got_r_num
    WHERE     r_num     <= 20
    ;
    

    That actaully could take more than 20 people: If there be a tie, it includes any person who is entitled to be in the top 20. If you want exactly 20 people, then add the columns of tiebreaker to analytical or use ROW_NUMBER instead of RANK ORDER BY clause.

  • calculate data for the last 30 days according to the date of sys

    SELECT DT, ITEMCODE, ITEMNAME, QTY
    FROM   TABLE1
    In above given the query, how do I calculate the details of the amount of the last 30 days, APR, MAY, and JUNE

    As the month during JULY, August, the amount of detail is required for the last 30 days (from sysdate), MAY, JUNE, July

    Please suggest.

    Yogesh

    Published by: user12957777 on July 28, 2010 03:16

    Hello

    CASE expressions can filter data in specific columns:

    SELECT     SUM ( CASE
                WHEN dt >= ADD_MONTHS ( TRUNC (SYSDATE, 'MONTH')
                             , -3
                             )
                AND  dt <  ADD_MONTHS ( TRUNC (SYSDATE, 'MONTH')
                             , -2
                             )
                THEN qty
               END
             )          AS third_month
    ,     SUM ( CASE
                WHEN dt >= ADD_MONTHS ( TRUNC (SYSDATE, 'MONTH')
                             , -2
                             )
                AND  dt <  ADD_MONTHS ( TRUNC (SYSDATE, 'MONTH')
                             , -1
                             )
                THEN qty
               END
             )          AS second_month
    ,     SUM ( CASE
                WHEN dt >= ADD_MONTHS ( TRUNC (SYSDATE, 'MONTH')
                             , -1
                             )
                AND  dt <               TRUNC (SYSDATE, 'MONTH')
                THEN qty
               END
             )          AS last_month
    ,     SUM ( CASE
                WHEN dt >= TRUNC (SYSDATE) - 30
                AND  dt <  TRUNC (SYSDATE)
                THEN qty
               END
             )          AS last_30_days
    FROM     table1
    ;
    

    You can do this with GROUP BY, in addition, if you want to separate for each itemname (for example) lines.

    I guess some things, like what do you mean by the last 30 days.

    If you wish to post a few 9creation TABLE or INSERT sample data) and the results you want from this data, then I could test this.

  • Why machine did transfer spontaneously inbox the last 15 days in a folder named Archive / 2015?

    I got lucky that I could find where the machine had hidden messages the last 15 days.
    Am I punished for having too many messages in the box at, or what?

    Hello, you're posting in the firefox support forum - firefox is a browser and does not handle your emails. in case you use thunderbird as a mail client and you have a question about this, please say so, then we will go to your question in the queue of thunderbird.
    If you access your email via webmail, please contact your e-mail provider to help you...

    Problems with email and how to find help

  • For the last 2 days everytime I open to MY MSN, it opens in safe mode. I deleted cookies and the history of FF. all other sites open OK. Vista, 64-bit operating system.

    Vista 64 bit OS

    Thanks for the replies, the problem was on the Microsoft site itself and internal glitch for the last 2 days on the garbled causing MY MSN page without graphics and text.

Maybe you are looking for

  • Why the clip will not play in the window of the observer?

    Hello world. It's me again. So, I just started working on a project, and the clip will not play in the window of the observer. In the timeline panel, I see that there are images to play, but the Viewer is black when I try to play. I have temporary ca

  • Satellite P30 - screen got vertical stripes

    Hello! Two problems: 1. my Satellite P30 becomes a little old (bought in 2005), I know, but it works really well - a few hiccups of course.However, the lines of different colors appear vertically on the screen. It started with a single line of a few

  • Pavilion g6-2306el: life of the battery and using the laptop all day

    Hello I tend to use the laptop for work almost all day. If this is the case, she recommends simply detach the battery, instead of always keep at full load (since it has plugged all the time)? Thank you.

  • amplitude of the waveform graph

    Hi guys,. could you please tell me how to control the amplitude of a waveform graph. I want the mV amplitude, and I want to control the scale of numbers also. Thank you Bill David

  • 310 - 1125y in expansion with the new video card?

    I have a HP all-in-one TouchSmart 310-1125y and would like to know if this PC support the installation of a new video card.  It comes with an integrated ATI Radeon HD 4270 support.  I did some research and have the impression that this PC is not part