Date range of Split by year wise

I have a situation where I need I split date rang dated by year wise

the rank can span one or more year as follows: 01 12, 2015 at 12/01/2017

I need this to divide:

12/01/2015 to 31/12/2015

01/01/2016 to 12/31/2016

01/01/2017 at 12/01/2017

My goal to solve this problem

(0.03 * 12 * no day) / no day year

for leap years the result will be different so do I need to divide the date interval

or any better solution

This will caculate rent tax on contracts for the duration of the contract

Thank you

my bad, I even if it was for the month, try this

SQL > with t as

() 2

3. Select to_date('01-12-2015','dd-mm-yyyy') datefrom, dateto of double to_date('12-01-2017','dd-mm-yyyy')

4)

5. Select

6-case when datefrom > trunc (add_months (datefrom,(level-1) * 12), 'YEAR')

7 then datefrom other end datefrom of trunc (add_months (datefrom,(level-1) * 12), 'YEAR').

8-case when dateto<>

9 then dateto another trunc (add_months (datefrom, (level) * 12), 'YEAR')-1 end dateto

10 t

11. connect by level<=>

DATEFROM, DATETO

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

1 DECEMBER 15 DECEMBER 31, 15

JANUARY 1ST, 16 DECEMBER 31, 16

1 JANUARY 17 JANUARY 12, 17

Tags: Database

Similar Questions

  • extraction of data each month and year wise in a table

    Hello...

    I have a table as raw material

    indicator dateofmateria clinker OPC ppc
    35 22 23/11/2 / 2012 CS
    45 87 78 23/11/2012 D
    55 90 100 11/23/2012 P
    4 45 24/11/27/2012 CS
    52 25 48 24/11/2012 D
    58 50 103 24/11/2012 P
    5 50 25/1 / 11 / 2012 CS
    45 17 55 11/25/2012 D
    45 77 55 25/11/2012 P...
    Here P indicates that the production of material, D flag show send material and CS flags shows the closing stock respective dates.

    I just want to calculate the difference in stock for the respective dates.
    I want to calculate the difference in stock as below for example particular date 23/11/2012-

    Difference in stock (OPC) = ((SUM * (OPC) where flag P = & month = 'nov')-(* SUM * (OPC) where flag = D & month = 'nov')-(* SUM * (OPC) where flag = CS & month = 'nov') *)

    Similarly for the PPC and also clinker.

    I want to calculate the difference in stock simultaneously for all the month of a given year that is seized by use

    I m using the following question for this...
    * Select to_char(a.dateofmtrl,'mon'), sum (a.rm1) - sum (b.rm1) - sum (c.rm1) OPC, sum (a.rm2) - sum (b.rm2) - sum (c.rm2) PPC, sum (a.rm3) - sum (b.rm3) - sum (c.rm3) CLINKER
    rawmtrl_graph a.,
    b rawmtrl_graph,
    c rawmtrl_graph
    where
    TO_CHAR (a.dateofmtrl, 'yyyy') = '2012' and
    TO_CHAR (b.dateofmtrl, 'yyyy') = '2012' and
    TO_CHAR (c.dateofmtrl, 'yyyy') = '2012' and
    a.mtrl_flag = 'P' and
    b.mtrl_flag = has ' and
    'c.mtrl_flag =' CS
    To_char Group (a.dateofmtrl, 'my')
    BUT IT IS DOES NOT CALCULATE THE STOCK OF MUTUAL FUNDS, PPC, CLINKER WITH PRECISION (WHICH GIVES SOME FIGURE UNEXPECTEDLY FOR EACH MONTH OF THE YEAR).

    PLEASE HELP ME IN THIS...
    I WANT TO CALCULATE THE STOCK DIFFERENCE YEAR WISE ALSO...

    THANKS AND GREETINGS

    VISHAL AMINE

    Well your three requests were not being met, then you would have generated a Cartesian product. Try the following:

    SELECT TO_CHAR(a.dateofmtrl,'mon'),
           SUM(a.rm1) - SUM(b.rm1) - SUM(c.rm1) OPC,
           SUM(a.rm2) - SUM(b.rm2) - sum(c.rm2) PPC,
           SUM(a.rm3) - sum(b.rm3) - sum(c.rm3) CLINKER
    FROM   rawmtrl_graph a
           INNER JOIN rawmtrl_graph b
           ON a.dateofmtrl = b.dateofmtrl
           INNER JOIN rawmtrl_graph c
           ON a.dateofmtrl = c.dateofmtrl
    WHERE  to_char(a.dateofmtrl,'yyyy')='2012'
    AND    to_char(b.dateofmtrl,'yyyy')='2012'
    AND    to_char(c.dateofmtrl,'yyyy')='2012'
    AND    a.mtrl_flag='P'
    AND    b.mtrl_flag='D'
    AND    c.mtrl_flag='CS'
    GROUP BY TO_CHAR(a.dateofmtrl,'mon');
    
  • is there an easy way to get the number of months in a year in a date range?

    Hi, experts, I am a newbie.

    are there any easy ways to get the number of months in a year in a date range?

    I would like to write a user-defined function.

    the input parameters are startdate, enddate, year

    the output is a number, not a month.

    for example, case 1

    StartDate = 01032009 (DDMMYYYY)
    end date = 28022010 (DDMMYYYY)
    If the year 2009, the output is 10
    If the year = 2010, the output is 2

    case 2:

    StartDate = 10032009 (DDMMYYYY)
    end date = 15032010 (DDMMYYYY)
    If the year 2009, the output is 10
    If the year = 2010, the output is 3

    Thank you very much!

    Hello

    You can (also) try this:

    SQL> with s as (
      2  ------------ Sample data -------------
      3  select to_date('01032009','ddmmyyyy') startdt, to_date('28022010','ddmmyyyy') enddt, 2009 yr from dual
      4  union all
      5  select to_date('01032009','ddmmyyyy') startdt, to_date('28022010','ddmmyyyy') enddt, 2010 yr from dual
      6  union all
      7  select to_date('10032009','ddmmyyyy') startdt, to_date('15032010','ddmmyyyy') enddt, 2009 yr from dual
      8  union all
      9  select to_date('10032009','ddmmyyyy') startdt, to_date('15032010','ddmmyyyy') enddt, 2010 yr from dual
     10  ------------ Sample data -------------
     11  )
     12  select startdt, enddt, yr,
     13  months_between(
     14          least(trunc(to_date(yr+1,'yyyy'),'year') , add_months(trunc(enddt,'month'),1))
     15          , greatest(trunc(to_date(yr,'yyyy'),'year') , trunc(startdt,'month'))
     16  ) nbmonths
     17  from s;
    
    STARTDT    ENDDT              YR   NBMONTHS
    ---------- ---------- ---------- ----------
    01/03/2009 28/02/2010       2009         10
    01/03/2009 28/02/2010       2010          2
    10/03/2009 15/03/2010       2009         10
    10/03/2009 15/03/2010       2010          3
    

    It's pretty simple. (no connection with, without functions SQL only integrated multicast, etc...)

  • To add totals in a certain date range

    I have 3 sheets. Income, expenses and then an annual journal (has twelve columns, one for each month). Is there a way to get the numbers to add totals to a column of the spreadsheet of spending within the date range 01/01/16 and 31/01/16 and put the total in a cell in January on my sheet of each year. I can't understand a formula so that it can find the date range. I get a synyax error message.

    Assumptions:

    Your TABLES (not the leaves) are named income, spending and summary. Here is any other tables in the document with these names.

    Dates of expenditure are in column A of the table expenses. Other than the header line, all the entries in this column are values Date and time that have been entered as dates only.

    The amount for each item of expenditure is in column C of the expense table.

    Line 1 of the analytical table is defined as a header line.

    January is in column A of the summary table.

    Summary::A1 cell contains the date January 1, 2016, but can be formatted to display only the name of the month or the month and year. (but see the note below) *.

    Enter the formula in the cell that will contain total expenditures recorded with dates in January 2016 below:

    = SUMIFS ("Expenses: Expenses, $C: $A," > = "& A1, Expenses: $A," < = "& EOMONTH(A1,0))

    Example: All the amounts of expenditure were reduced to 1.00 simple confirmation of funds.

    * NOTE: The formula has previously worked with the format of the cells in the row 1 Summary defined to show only the month and the year (two digits) of the effective date values (the first day of the month indicated), but the table I built tonight January 1, 2015 to the format to display 16 Jan, one was interpreted as January 16 (2016) , and SUMIFS formula did not include not January 1 to January 14 numbers in January total.

    A custom, displaying the month (short or long) and the year (four digits) or a custom format shows only the name of the month (short or long) gave good results.

    Note that any format under control of the display, the effective date is the first of the month displayed.

    Table built and tested in Numbers ' 09 (v 2.3)

    Kind regards

    Barry

  • Smart album by date range does not select all the pictures, it should.

    I created a Smart Album with a range of the year.

    Some pictures appear in the Smart Album, but others do not, even though their information shows that their date corresponds to the range.

    I tried a repair of the photo library database, but that did not help.

    Try breaking the rule of date range: a buggy behavior reported in some language settings.

    This version shows more photos?

  • The smart Albums based on the date range cause app Crash Photos

    While I'm setting up a new Smart Album based on day of photos between 12/01/2015 and 31/12/2015 the Photos app closes with a crash. Cannot set the second date (the end date for this album). However, I can easily create a new Smart Album for next month (01/01/2016 and 01/31/2016). I create smart Albums, because the new Photos app does not like the old iPhoto does with my Photos from the photo gallery.

    How can I solve this? I don't have an album of December...? !

    You are in an area where the date format is different from the United States?  Earlier this year, we have seen small business issues have reported that rules for smart albums date range do not work with the primary language set to French or German.

    Try to change the primary system language to English with an English date format. Photos could be trying to read the 12/31/2015 as the 12th day of the month 31.

    Or use a different date based on 'before' rule and after.

  • Search for files by name, date range, size, content, etc.

    I just changed from windows XP pro to win 7 pro 64.  For twenty years, I used the "Norton File Manager" who does not work under Windows 7 Pro 64 bit.  I became dependent on its ability to search relatively sophisticated as by date range, size, content, name, etc.  I guess that Windows 7 has something like this, but I'm not.  Can you help me?

    On Tuesday, March 19, 2013 15:09:13 + 0000, csvideo wrote:

    I just changed from windows XP pro to win 7 pro 64.  For twenty years, I used the "Norton File Manager" who does not work under Windows 7 Pro 64 bit.  I became dependent on its ability to search relatively sophisticated as by date range, size, content, name, etc.  I guess that Windows 7 has something like this, but I'm not.  Can you help me?

    I recommend two different third-party search programs, both free:

    1. search everything, which is faster if you search by file name
    (http://www.voidtools.com/)

    2. agent Ransack, which is the best for finding content, etc.
    http://www.Mythicsoft.com/page.aspx?type=agentransack&page=home

  • AMOUNT of Oracle with the date range

    Hello community,

    I'm having a problem with the addition of a field with a date range. It comes to my table

    JVREFVARCHAR210------
    SOURCEVARCHAR22------
    PERIODVARCHAR26------
    JVDATENUMBER-380-Nullable--
    GLCODEVARCHAR224------
    DESCRVARCHAR240---Nullable--
    AMOUNT_0FLOAT4848--Nullable--
    AMOUNT_1FLOAT4848--Nullable--
    JVTYPEVARCHAR24

    and I'm glad the the following statement works as expected

    SELECT AMOUNT_1 FROM 'TABLE' where

    TO_DATE ("PERIOD, ' YYYYMM") > = to_date ("'201501 ',' YYYYMM")

    and

    TO_DATE (PERIOD, 'YYYYMM') < = to_date ("'201502 ',' YYYYMM");

    E.g.

    AMOUNT_1

    56192.48

    59863.57

    48570.1

    72407.12

    21626.96

    35532.96

    75860.67

    25623.62

    54799.83

    16872.3

    The next thing I want to do is the sum of these amounts... so I changed my statement to become

    SELECT SUM (AMOUNT_1) 'TABLE' where

    TO_DATE ("PERIOD, ' YYYYMM") > = to_date ("'201501 ',' YYYYMM")

    and

    TO_DATE (PERIOD, 'YYYYMM') < = to_date ("'201502 ',' YYYYMM");

    and now I'm getting

    ORA-01841: (full) year must be between-4713 and 9999 and not 0

    I also tried

    SELECT THE PERIOD (AMOUNT_1) SUM OF "BRE". "' OPW_NMLTRX ' where

    TO_DATE ("PERIOD, ' YYYYMM") > = to_date ("'201501 ',' YYYYMM")

    and

    TO_DATE (PERIOD, 'YYYYMM') < = to_date ("'201502 ',' YYYYMM")

    Group by PERIOD

    with the same results... I can't figure out what I should do next?

    Thank you.

    Hello

    Solomon Yakobson says:

    Question:

    SELECT *.

    From your_table

    WHERE the TO_NUMBER (SUBSTR (PERIOD, 1, 4)) NO BETWEEN-4713 and 9999

    OR TO_NUMBER (SUBSTR (PERIOD, 1, 4)) = 0

    /

    To find the offending rows.

    SY.

    This can cause other errors, according to what is in this column.  A better way would be something like:

    Primary_key SELECT, period - add more columns you want

    'TABLE' - avoid names which need quotation marks

    (Period WHERE the TRANSLATION)

    '012345678'

    '999999999'

    ) <> = "999999"

    OR SUBSTR (period, 1, 4), not BETWEEN "1900" AND "2099"

    OR SUBSTR (period 5) NOT BETWEEN '01' to '12'

    ;

    Now there may be errors of conversion, because there is no conversion.

  • Date range

    Hi Experts,

    Kindly inviting you to advise how to generate a Date Range as

    JAN-01-14

    JAN02-14

    JAN03-14

    JAN04-14

    .

    .

    .

    .

    UP TO

    DEC-31-14 or any DATE i.e Date between two months as JAN - 14 JUL-14.

    Also, please indicate how do if I need to generate it between two years as 2013 and 2015.

    Hello

    Saroha Amit wrote:

    Hi Frank,.

    Please suggest where to use TO_CHAR in your suggestion.

    Rather than display a DATE in the SELECT clause, you can use TO_CHAR, where 1 is the DATE, like this:

    WITH target_dates AS

    (

    SELECT DATE ' 2014-01-01' AS first_date

    , DATE '' 2014-01-04 AS last_date

    OF the double

    )

    SELECT TO_CHAR ( first_date + LEVEL - 1).

    , "MONDD-YYYY".

                    )       AS a_date

    OF target_dates

    CONNECT BY LEVEL<= 1="" +="" last_date="" -="">

    ;

  • Date ranges query

    Hi Experts,

    A very happy new year to all of you (a little in advance)!

    I have a table where I have the id of employee and the task assigned with the start dates and end dates. Overlap in the dates of the tasks is a data delivers however I know how to spot them and eliminate. There is therefore no date of tasks that overlap

    Employee_id

    Task_No

    Task_Start_date

    Task_End_Date

    Examples of data

    1 T1 1 January 2014 February 28, 2014

    1 T2 March 1, 2014 31 December 2014

    2 T1 23 January 2014 31 December 2014

    2 T2 1 January 2015 December 31, 2073 (means end of time)

    3 T3 1 January 2014 July 15, 2014

    3 T4 August 1, 2014 31 December 2014

    T5 4 1 January 2014 December 31, 2073

    I want to design a query where I provide the end date and it will list all the employees that are free for the same day from 1 January 2014. Thus, for example, if I give December 31, 2014, it will list the

    EmpId (first day where the employee is free)

    2 January 1, 2014

    3 July 16, 2014

    If I give the end = end date of time(31-Dec-2013), result-

    EmpId (first day where the employee is free)

    1 January 1, 2015

    2 January 1, 2014

    3 July 16, 2014

    If I give the end = date January 31, 2014, expected - result

    EmpId (first day where the employee is free)

    1 January 1, 2015

    I conceived after the request, but he intercepted not 2 employee ID. Also, it provides no flexibility to change end date-

    Select *.

    from (select employe_id,

    task_start_date,

    task_end_date,

    lag (task_end_date, 1, task_start_date) on prev_end_date (partition by employee_id arrested by task_start_date)

    of shop.employee_tasks

    where task_end_date > = trunc (sysdate))

    where task_start_date - prev_end_date > 1

    Thanks in advance!

    Kind regards

    This is an example of what I call the query 'free time': you have the dates when you are busy and you want the dates where you are free.

    You can find a nice solution for the problem of base here: ask Tom "SQL Query to find gaps in the date ranges" (search for solution of Anthony Boucher). Please note that this solution works even with the date ranges overlap.

    To apply the solution here, first create the test data (please do it yourself in the following questions).

    create table t(Employee_id, task_no, Task_Start_date, task_end_date)
    as select
    1, 'T1', to_date('01-jan-2014'), to_date('28-feb-2014') from dual union all select
    1, 'T2', to_date('01-Mar-2014'), to_date('31-Dec-2014') from dual union all select
    2, 'T1', to_date('23-jan-2014'), to_date('31-dec-2014') from dual union all select
    2, 'T2', to_date('01-jan-2015'), to_date('31-dec-2073') from dual union all select
    3, 'T3', to_date('01-jan-2014'), to_date('15-jul-2014') from dual union all select
    3, 'T4', to_date('01-aug-2014'), to_date('31-dec-2014') from dual union all select
    4, 'T5', to_date('01-Jan-2014'), to_date('31-Dec-2073') from dual;
    

    In the query, you must add records for yesterday and for the "end date" you want. This allows you to "free time" before and after the date ranges in your table.

    Now, you partition by order of Task_Start_date and employe_id. Using the analytical function of the max (task_end_date), you get the last date of end so far. Add 1 and you get the first time (maybe). To make sure that the date is free, it must be before the next start date.

    variable end_date varchar2(64)
    exec :end_date := '31-Dec-2073';
    --
    with boundaries as (
      select trunc(sysdate)-1 task_start_date, trunc(sysdate)-1 task_end_date from dual
      union all
      select to_date(:end_date)+1, to_date(:end_date)+1 from dual
    ), data as (
      select * from t
    where task_end_date >= trunc(sysdate)
      and task_start_date < :end_date
      union all
      select distinct a.employee_id, null, b.task_start_date, b.task_end_date
      from t a, boundaries b
    )
    select employee_id, min(free_start) free_start
    from (
      select employee_id,
      max(task_end_date) over (partition by employee_id order by task_start_date)+1 free_start,
      lead(task_start_date) over (partition by employee_id order by task_start_date)-1 free_end
      from data
    )
    where free_start <= free_end
    group by employee_id;
    
    EMPLOYEE_ID FREE_START
    1 JANUARY 1, 15
    2 1 JANUARY 14
    3 16 JULY 14
  • Receive every month between date Range

    Hi all

    I said you want to display the month and year for the date range. IE Start date: 01-11-12, end Date: 31/05/13

    SELECT COUNT(T1.CUST_NM) AS COUNT, TO_CHAR(T1.CREATE_DT,'MON-YY') AS MONTH, SUM(T3.DISBURSEMENT_LIMIT) AS TOTAL
      FROM CUSTOMER T1, 
     ACCOUNT T2, LOAN_ACCOUNT T3, CREDIT_APPL T4, PORTFOLIO T5 WHERE  T1.CUST_ID = T2.CUST_ID  AND T2.ACCT_ID = T3.ACCT_ID  AND T3.APPL_ID = T4.APPL_ID  AND 
     T4.PORTFOLIO_ID = T5.PORTFOLIO_ID
    and t1.CREATE_DT between to_date('01-01-10','DD-MM-YY') and  to_date('30-12-10','DD-MM-YY') 
     GROUP BY TO_CHAR(T1.CREATE_DT,'MON-YY')
    
    
    
    


    Exit SQL:

    CountyMonth-yearTotal
    8JAN-1015300
    6FEB-104245000
    11AUG-10144500
    6DEC-1015500

    Now SQL returns matching records to date. But the requirement is to display the name of the month, the number and total 0 if there is no data found.

    Power required:

    County Month-year Total
    8Jan15300
    1Feb-10118750
    0March-100
    0Apr-100
    0May - 100
    0Jun - 100
    0Jul-100
    11Aug-10144500
    0Seven.-100
    0Oct-100
    0Nov - 100
    6Dec - 1015500

    Please suggest me SQL to archive the above of the requirement.

    Thanks and greetings

    Saami

    Try this

    with t

    as

    (

    Select count (t1.cust_nm) as County

    to_char(t1.create_dt,'mon-yy') per month

    , sum (t3.disbursement_limit) total

    the t1 client

    in t2

    loan_account t3

    credit_appl t4

    the t5 portfolio

    where t1.cust_id = t2.cust_id

    and t2.acct_id = t3.acct_id

    and t3.appl_id = t4.appl_id

    and t4.portfolio_id = t5.portfolio_id

    and t1.create_dt between to_date ('01-01-10', ' dd-mm-yy')

    and to_date ('30-12-10', ' dd-mm-yy')

    Group

    by to_char(t1.create_dt,'mon-yy')

    )

    t1

    as

    (

    Select to_char (add_months (to_date('01-01-10','dd-mm-yy'), level-1), 'Mon - yy') month_list

    of the double

    connect

    by add_months (to_date('01-01-10','dd-mm-yy'), level-1)<= >

    )

    Select nvl (t.count, 0) as County

    t1.month_list per month

    , nvl (t.total, 0), as total

    from t1

    left

    Join t

    on t1. month_list = t.month

  • Impossible to get Min, Max and median of the values in the date range values

    Hello

    I had a requirement as to show the data of each charge group of wise men as '< 100' ' 100-199 "" 200-299 "" 300-399 "400-499, 500-599 600-699 700-799 800-899 900-999 > = 1000 '"»

    With the query be able to get the count between the beach and the total below. But impossible to get the Min and Max values for this range. For example if the County < 100 is 3 then in these 3, the lowest value is need to display in the min. Idem for Max column also.

    In the light of the median value on these values.

    Thanks in advance.



    Requirement is as below:
    State < 100 100-199, 200-299 300-399 400-499, 500-599 600-699 700-799 800-899 900-999 > = 1000 Min Total median Max
    AK 1 2 0 4 1 4 4 35 35 4 1 $25 $85 850 $1,200
    AL 0 0 2 27 10 17 35 2 2 35 0 $103 100-$1 500 750


    * "QUERY ' * '"

    WITH t AS
    (SELECT 'AL' State, 12 DUAL FROM VALUE
    UNION ALL
    SELECT 'AL' State, 67 FROM DUAL VALUE
    UNION ALL
    SELECT 'AL' State, 23 FROM DUAL VALUE
    UNION ALL
    SELECT 'AL' State, 12 DUAL FROM VALUE
    UNION ALL
    SELECT 'AL' State, 12 DUAL FROM VALUE
    UNION ALL
    SELECT 'AL' State, 78 FROM DUAL VALUE
    UNION ALL
    SELECT 'AL' State, 34 FROM DUAL VALUE
    UNION ALL
    SELECT 'AL' State, 4 DUAL FROM VALUE
    UNION ALL
    SELECT 'AL' State, 12 DUAL FROM VALUE
    UNION ALL
    SELECT 'AL' State, 15 VALUE FROM DUAL
    UNION ALL
    SELECT "AZ" State, FROM DUAL VALUE 6
    UNION ALL
    SELECT "AZ" State, 123 FROM DUAL VALUE
    UNION ALL
    SELECT "AZ" State, 123 FROM DUAL VALUE
    UNION ALL
    SELECT 'MY' State, 23 FROM DUAL VALUE
    UNION ALL
    SELECT 'MY' State, 120 FROM DUAL VALUE
    UNION ALL
    SELECT 'MY' State, 456 FROM DUAL VALUE
    UNION ALL
    SELECT 'MY' State, 11 FROM DUAL VALUE
    UNION ALL
    SELECT 'MY' State, 24 FROM DUAL VALUE
    UNION ALL
    SELECT 'MY' State, 34 FROM DUAL VALUE
    UNION ALL
    SELECT 'MY' State, 87 DUAL FROM VALUE
    UNION ALL
    SELECT 'MY' State, 23 FROM DUAL VALUE
    UNION ALL
    SELECT 'MY' State, 234 DUAL FROM VALUE
    UNION ALL
    SELECT 'MY' State, 789 FROM DUAL VALUE
    UNION ALL
    SELECT "HD" State, VALUE FROM DUAL 54321).
    -End of test data
    AS T1
    (SELECT State,
    NVL (COUNT (DECODE (VALUE, 0, 0)), 0) '< 100 ',.
    NVL (COUNT (DECODE (VALUE, 1, 1)), 0) '100-199.
    NVL (COUNT (DECODE (VALUE, 2, 2)), 0) '200-299.
    NVL (COUNT (DECODE (VALUE, 3, 3)), 0) '300-399.
    NVL (COUNT (DECODE (VALUE, 4, 4)), 0) '400-499.
    NVL (COUNT (DECODE (VALUE, 5, 5)), 0) '500-599,'
    NVL (COUNT (DECODE (VALUE, 6, 6)), 0) '600-699.
    NVL (COUNT (DECODE (VALUE, 7, 7)), 0) '700-799.
    NVL (COUNT (DECODE (VALUE, 8, 8)), 0) '800-899.
    NVL (COUNT (DECODE (VALUE, 9, 9)), 0) '900-999. "
    NVL (COUNT (DECODE (VALUE, 10, 10)), 0) ' > = 1000.
    (SELECT STATE,
    CASE
    WHAT VALUE < 100 THEN 0
    WHAT A VALUE BETWEEN 100 AND 199 THEN 1
    WHAT VALUE BETWEEN 200 AND 299, THEN 2
    WHAT VALUE BETWEEN 300 AND 399 THEN 3
    WHAT VALUE BETWEEN 400 AND 499 THEN 4
    WHAT VALUE BETWEEN 500 AND 599 5 THEN
    WHAT VALUE BETWEEN 600 AND 699 6 THEN
    WHAT VALUE BETWEEN 700 AND 799 THEN 7
    WHAT VALUE BETWEEN 800 AND 899 8 THEN
    WHAT VALUE FROM 900 TO 999 9 THEN
    WHAT VALUE > = 10 THEN 1000
    END
    VALUE
    T)
    GROUP BY State)
    SELECTION STATE,
    "< 100."
    "100-199.
    "200 299",
    "300-399.
    "400-499.
    '500-599,'
    "600-699.
    "700-799.
    "800-899.
    "900-999."
    "> = 1000."
    '< 100 '.
    + "100-199.
    + "200-299.
    + '300-399.
    + '400-499.
    + "500-599.
    + '600-699.
    + "700-799.
    + "800-899.
    + '900-999 ".
    + ' > = 1000.
    in total,.
    less ("< 100",)
    "100-199.
    "200 299",
    "300-399.
    "400-499.
    '500-599,'
    "600-699.
    "700-799.
    "800-899.
    "900-999."
    ("> = 1000 ') min_val,.
    largest ("< 100",)
    "100-199.
    "200 299",
    "300-399.
    "400-499.
    '500-599,'
    "600-699.
    "700-799.
    "800-899.
    "900-999."
    ("> = 1000 ') max_val
    FROM t1
    /

    Why not keep it simple?

    WITH t AS
    (SELECT 'AL' state, 12 VALUE FROM DUAL
    UNION ALL
    SELECT 'AL' state, 67 VALUE FROM DUAL
    UNION ALL
    SELECT 'AL' state, 23 VALUE FROM DUAL
    UNION ALL
    SELECT 'AL' state, 12 VALUE FROM DUAL
    UNION ALL
    SELECT 'AL' state, 12 VALUE FROM DUAL
    UNION ALL
    SELECT 'AL' state, 78 VALUE FROM DUAL
    UNION ALL
    SELECT 'AL' state, 34 VALUE FROM DUAL
    UNION ALL
    SELECT 'AL' state, 4 VALUE FROM DUAL
    UNION ALL
    SELECT 'AL' state, 12 VALUE FROM DUAL
    UNION ALL
    SELECT 'AL' state, 15 VALUE FROM DUAL
    UNION ALL
    SELECT 'AZ' state, 6 VALUE FROM DUAL
    UNION ALL
    SELECT 'AZ' state, 123 VALUE FROM DUAL
    UNION ALL
    SELECT 'AZ' state, 123 VALUE FROM DUAL
    UNION ALL
    SELECT 'MA' state, 23 VALUE FROM DUAL
    UNION ALL
    SELECT 'MA' state, 120 VALUE FROM DUAL
    UNION ALL
    SELECT 'MA' state, 456 VALUE FROM DUAL
    UNION ALL
    SELECT 'MA' state, 11 VALUE FROM DUAL
    UNION ALL
    SELECT 'MA' state, 24 VALUE FROM DUAL
    UNION ALL
    SELECT 'MA' state, 34 VALUE FROM DUAL
    UNION ALL
    SELECT 'MA' state, 87 VALUE FROM DUAL
    UNION ALL
    SELECT 'MA' state, 23 VALUE FROM DUAL
    UNION ALL
    SELECT 'MA' state, 234 VALUE FROM DUAL
    UNION ALL
    SELECT 'MA' state, 789 VALUE FROM DUAL
    UNION ALL
    SELECT 'MH' state, 54321 VALUE FROM DUAL)
    SELECT state
         , NVL( COUNT( case when VALUE < 100 then 0 end ), 0 ) "<100"
         , NVL( COUNT( case when VALUE between 100 and 199 then 0 end ), 0 ) "100-199"
         , NVL( COUNT( case when VALUE between 200 and 299 then 0 end ), 0 ) "200-299"
         , NVL( COUNT( case when VALUE between 300 and 399 then 0 end ), 0 ) "300-399"
         , NVL( COUNT( case when VALUE between 400 and 499 then 0 end ), 0 ) "400-499"
         , NVL( COUNT( case when VALUE between 500 and 599 then 0 end ), 0 ) "500-599"
         , NVL( COUNT( case when VALUE between 600 and 699 then 0 end ), 0 ) "600-699"
         , NVL( COUNT( case when VALUE between 700 and 799 then 0 end ), 0 ) "700-799"
         , NVL( COUNT( case when VALUE between 800 and 899 then 0 end ), 0 ) "800-899"
         , NVL( COUNT( case when VALUE between 900 and 999 then 0 end ), 0 ) "900-999"
         , NVL( COUNT( case when VALUE >= 1000 then 0 end ), 0 ) ">=100"
         , count( value ) "total"
         , min( VALUE ) "min"
         , max( VALUE ) "max"
         , avg( VALUE ) "avg"
         , median( value ) "median"
    from t
    group by state
    
  • Year-Wise break-up

    Hi all

    I have a table1 with reel number and registration date of students as described below:-

    TABLE1:
    ROLLNO REGST
    1 APRIL 1, 2002
    2 1ST OCTOBER 2004
    3 DECEMBER 22, 2005
    4 NOVEMBER 5, 2006
    5 JANUARY 3, 2007
    6 AUGUST 12, 2008
    7 DECEMBER 22, 2008
    8 DECEMBER 22, 2008
    9 11-SEP-2010

    where the output should me as the burst year-wise for the year 2005-07, 2008-09 and 2009-10

    --------------------------------------------------------------------------------
    2005-2007-2008-2009 2009-20010
    ----------------------------------------------------------------------------------
    3 3 1








    the collapse of the year-wise for the year 2007-08, 2008-09 and 2009-10

    Published by: user8807592 on 10 Sep, 2010 20:32

    where the output should me as the burst year-wise for the year 2005-07, 2008-09 and 2009-10

    is not year-wise and goes against:

    the collapse of the year-wise for the year 2007-08, 2008-09 and 2009-10

    From what I can make of it:

    SQL> -- generating sample data:
    SQL> with table1 as (
      2  select 1 rollno, to_date('1-APR-2002', 'dd-mon-yyyy') regst from dual union
      3  select 2, to_date('1-OCT-2004', 'dd-mon-yyyy') from dual union
      4  select 3, to_date('22-DEC-2005', 'dd-mon-yyyy') from dual union
      5  select 4, to_date('5-NOV-2006', 'dd-mon-yyyy') from dual union
      6  select 5, to_date('3-JAN-2007', 'dd-mon-yyyy') from dual union
      7  select 6, to_date('12-AUG-2008', 'dd-mon-yyyy') from dual union
      8  select 7, to_date('22-DEC-2008', 'dd-mon-yyyy') from dual union
      9  select 8, to_date('22-DEC-2008', 'dd-mon-yyyy') from dual union
     10  select 9, to_date('11-SEP-2010', 'dd-mon-yyyy') from dual
     11  )
     12  --
     13  -- actual query:
     14  --
     15  select sum(range1)  "2005-2007"
     16  ,      sum(range2)  "2008-2009"
     17  ,      sum(range3)  "2009-2010"
     18  from ( select case
     19                  when to_number(to_char(regst, 'yyyy')) between 2005 and 2007
     20                  then count(rollno)
     21                end range1
     22         ,      case
     23                  when to_number(to_char(regst, 'yyyy')) between 2008 and 2009
     24                  then count(rollno)
     25                end range2
     26         ,      case
     27                  when to_number(to_char(regst, 'yyyy')) between 2009 and 2010
     28                  then count(rollno)
     29                end range3
     30         from   table1
     31         group by regst
     32       );
    
     2005-2007  2008-2009  2009-2010
    ---------- ---------- ----------
             3          3          1
    
  • Reading of information within the given date range

    Hi all

    Please can u help me to solve this: -.

    I need to get these employees who completed their 18 years within the specified date range.

    For example, If date1 = 2008-10-21 and date2 = 03/11/2008

    Then, I need to display information of all employees whose birthday falls in the range of dates and the date.

    Thanks in advance!

    Hello

    Try this

    SELECT *.
    OF test1
    WHERE (TO_DATE('21/10/2008','DD/MM/YYYY') - bdate) / 365,24 > 18 OR (TO_DATE('30/10/2008','DD/MM/YYYY') - bdate) / 365,24 > 18

    -Pavan Kumar N

  • Conditional formatting depends on the date ranges

    Basically, I want to be able to enter a date in column A and a sum of money in the B column, depending on where the date in column A grave in a date range, I want the money in column B to copy to a corresponding column. Is this possible? The only questions I found on here deal in a conditional formatting with dates have to do with derivative.

    Thank you

    Julio

    I hope this help to clarify for you...

    It is not bringing conditional formatting.  Formatting conditional would change the format of a cell (or cells)... as the font, color, size, color cell background, or other formatting character is tics of a cell based on the contents of the cell

    You ask about including of the value of a cel another beach under certain conditions

    Here is an example:

    The first three rows are header lines.

    You must enter a valid date for the towing job.  Using the format "mm/dd/yyyy".

    C4 = IF (AND (DATEVALUE (A4) ≥DATEVALUE($B$1), DATEVALUE (A4) ≤DATEVALUE($B$2)), B4, "")

    It's shorthand dethrone select cell C4, and type (or copy and paste it here) the formula:

    = IF (AND (DATEVALUE (A4) ≥DATEVALUE($B$1), DATEVALUE (A4) ≤DATEVALUE($B$2)), B4, "")

    Select the cell C4, copy

    Select cells C4 at the end of the C column, paste

Maybe you are looking for

  • Already running vi "not compiled?

    I have a mixed device FPGA, we access by ethernet and I a VI on this unit and it works, and it's just wonderful. I have an application which refers to this VI. He used to work. Then we moved to another location and the network address has changed. We

  • Power Manager and display the brightness level

    Hello Laptop: ThinkPad Edge 13 In my settings (Power Manager v1.89) together is average brightness level of the display (for the AC and the battery settings), but for some reason any after the screensaver or change username or Stanby mode brightness

  • need to reinstall xp media center edition, but only xp professinal disc

    I have a computer with windows xp media center edition and want to reinstall the operating system, but I do not have the right disk. I have the certificate of authenticity, but I only have a disk of windows xp professional. How can I reinstall the op

  • Hidden on BlackBerry 8350i v4.6.1.112 menu

    When the user clicks the menu button, the menu is not displayed when the use of canvas or GameCanvas! I think that it is displayed behind the canvas. It is shown that when we use a Screen object! We have a J2ME application that works with more than 4

  • second app

    Hello everyone, I created my first app bb10 and sent into the world of the app and everything was fine, but I created a second application and when I send the file to the second application tells me that the application id is already in use, how can