Count of the number of months with unpaid for the last six months

Hello

I now table to store the daily presence of each employee

ATTENDANCESHEET

EMPID

PAYROLLDATE

UNPAID

1

10/01/2013

6

1

10/02/2013

2

1

11/01/2013

0

1

11/02/2013

0

1

12/01/2013

0

1

12/02/2013

0

1

01/01/2014

0

1

01/02/2014

0

1

02/01/2014

0

1

02/02/2014

0

1

03/01/2014

45

1

03/02/2014

0

2

03/01/2014

0

2

03/02/2014

0

I want to get the number of months used unpaid in the past 6 months (excluding the current).

If the month of payroll, I'm in treatment is 4, 2014, I spend 4 as payrollmonth and 2014 as payroll year

The application must check the latest 6 month data and number of months for which there is any unpaid value

In the case above for month 4, 2014, the power required is

EmpID

County

1

2

2

0

I use oracle 10g

EXAMPLES OF DATA

create the table attendancesheet as

(

Select 1 as empid, to_date (January 10, 2013 ',' DD/MM/YYYY ') as payrolldate, 6 paid by union double all the

Select 1 as empid, to_date (10 February 2013 ',' DD/MM/YYYY ') as payrolldate, 0 paid by union double all the

Select 1 as empid, to_date (January 11, 2013 ',' DD/MM/YYYY ') as payrolldate, 0 paid by union double all the

Select 1 as empid, to_date (February 11, 2013 ',' DD/MM/YYYY ') as payrolldate, 0 paid by union double all the

Select 1 as empid, to_date (12 January 2013 ',' DD/MM/YYYY ') as payrolldate, 0 paid by union double all the

Select 1 as empid, to_date (February 12, 2013 ',' DD/MM/YYYY ') as payrolldate, 0 paid by union double all the

Select 1 as empid, to_date (1 January 2014 ',' DD/MM/YYYY ') as payrolldate, 0 paid by union double all the

Select 1 as empid, to_date (February 1, 2014 ',' DD/MM/YYYY ') as payrolldate, 0 paid by union double all the

Select 1 as empid, to_date (January 2, 2014 ',' DD/MM/YYYY ') as payrolldate, 0 paid by union double all the

Select 1 as empid, to_date (February 2, 2014 ',' DD/MM/YYYY ') as payrolldate, 0 paid by union double all the

Select 1 as empid, to_date (3 January 2014 ',' DD/MM/YYYY ') as payrolldate, 45 paid by union double all the

Select 1 as empid, to_date (3 February 2014 ',' DD/MM/YYYY ') as payrolldate, 0 paid by union double all the

Select 2 as empid, to_date (3 January 2014 ',' DD/MM/YYYY ') as payrolldate, 0 as default all the double union

Select 2 as empid, to_date (3 February 2014 ',' DD/MM/YYYY ') as payrolldate, 0 paid double

);

Help, please

Hello

So, you want to count the distinct months for 6 months before (not included) the given month; is this fair?

Here's one way:

VARIABLE month VARCHAR2 (2)

Year VARIABLE VARCHAR2 (4)

EXEC: months: = '4';

EXEC: year: "2014"; =

WITH got_end_date AS

(

SELECT TO_DATE (: month |) '/' || : year

, ' MM/YYYY ".

) AS end_date

OF the double

)

SELECT a.empid

, COUNT (DISTINCT

CASE

WHEN a.unpaid > 0

THEN TRUNC (a.payrolldate, 'MONTH')

END

), Cnt

Of attendancesheet one

JOIN e-got_end_date WE a.payrolldate > = ADD_MONTHS (e.end_date-6)

AND a.payrolldate< >

GROUP BY a.empid

ORDER BY a.empid

;

If you use a WHERE clause to exclude the lines with some outstanding = 0 (or unpaid is NULL), then you would get no output for employees like empid = 2 in this example.  A WHERE clause ignores an entire line, so I used an expression BOX just a value.

Tags: Database

Similar Questions

  • I would like to get the list of all devices on which my creative cloud has been activated for the last six months or a year

    I would like to get the list of all devices on which my creative cloud has been activated for the last six months or a year

    I do not think that information... Adobe titles represent the only link I know following your accounts, but not where the programs are installed

    https://Accounts.adobe.com/ , then click on Plans & products above to find a list of your programs and your serial numbers

  • How can I look at the files sent over the last six months? Where did everything go?

    How can I recover the old addresses and old files "sent"?

    Hi bricana,

    Unless you have removed, you can see the files you sent by clicking on the files tab when you are logged into your account on https://cloud.acrobat.com/files.

    Please let us know if you have any additional questions.

    Best,

    Sara

  • Is why Adobe acting like I didn't pay the last 6 months?

    Today, for the first time in 6 months that adobe allow me to use it, I realize that my subscription might have worn out now, but the way he wants me to pay for more is saying that my trial has expired? I'm sorry if this is a lot of nothing I'm worried, but it seems that I had to pay to run a demo version of the software the last six months now... The software has been excellent all this while and I had all intend to renew my prescription, but now I'm second guessing myself a lot of time...

    Your subscription to cloud shows correctly on your account page?

    https://www.adobe.com/account.html for subscriptions on your page from Adobe

    If Yes

    Some general information for a subscription of cloud

    Sign out of your account of cloud... Restart your computer... Connect to your paid account of cloud

    -Connect using http://helpx.adobe.com/x-productkb/policy-pricing/account-password-sign-faq.html

    -http://helpx.adobe.com/creative-cloud/kb/sign-in-out-creative-cloud-desktop-app.html

    -http://helpx.adobe.com/x-productkb/policy-pricing/activation-network-issues.html

    -http://helpx.adobe.com/creative-suite/kb/trial--1-launch.html

    If no

    This is an open forum, Adobe support... you need Adobe personnel to help

    Adobe contact information - http://helpx.adobe.com/contact.html

    -Select your product and what you need help with

    -Click on the blue box "still need help? Contact us. "

  • Get the number of month, week and day between 2 dates

    Hi all

    Is it possible to display the number of months, weeks and days between 2 dates? by using only the SQL or PL/SQL...

    Entry:
    Date: October 1, 2010
    Date: October 19, 2010

    I want output like below (assuming starts the week from Monday to Sunday in oracle).

    October 1, 2010-(since it's in the middle of the week)
    October 2, 2010-(since it's in the middle of the week)
    October 3, 2010-(since it's in the middle of the week)
    40. (4 Oct-10 Oct falls into the 40th week of the year)
    41. (11 Oct-17 Oct falls into the 41st week of the year)
    October 18, 2010-(since it's in the middle of the week)
    October 19, 2010-(since it's in the middle of the week)


    Note: If there is a month between the date, the number of the month should be displayed.
    End of the month, the remaining date included with a full week, then the week of the year number should
    displayed. After posting the week, remaining dates should be displayed as it is...


    Appreciate your help...



    Thank you.
    Fox.

    You mean something like this...

    SQL> ed
    Wrote file afiedt.buf
    
      1  WITH t AS (select date '2010-09-27' as fdate, date '2010-11-21' as tdate from dual)
      2  --
      3  -- END OF TEST DATA
      4  --
      5  select dt2
      6  from (
      7        select dt,
      8               case when days_of_mn = days_in_month then 'Whole: '||to_char(dt,'Month')
      9                    when days_of_wk = 7 then 'Week: '||to_char(dt,'fmWW')
     10               else to_char(dt, 'DD-fmMonth-YYYY')
     11               end as dt2
     12              ,row_number() over (partition by
     13                 case when days_of_mn = days_in_month then to_char(dt,'Month')
     14                                  when days_of_wk = 7 then 'Week: '||to_char(dt,'fmWW')
     15                 else to_char(dt, 'DD-fmMonth-YYYY')
     16                 end order by dt) as rn
     17        from (
     18              select dt, wk, mn, days_in_month
     19                    ,count(*) over (partition by wk) as days_of_wk
     20                    ,count(*) over (partition by mn) as days_of_mn
     21              from (
     22                    select fdate+rownum-1 as dt
     23                          ,to_number(to_char(fdate+rownum-1,'fmWW')) as wk
     24                          ,to_number(to_char(fdate+rownum-1,'fmMM')) as mn
     25                          ,to_number(to_char(last_day(fdate+rownum-1),'fmDD')) as days_in_month
     26                    from t
     27                          connect by rownum <= tdate-fdate+1
     28                   )
     29             )
     30        ) x
     31  where rn = 1
     32* order by dt
    SQL> /
    
    DT2
    -----------------
    27-September-2010
    28-September-2010
    29-September-2010
    30-September-2010
    Whole: October
    Week: 44
    Week: 45
    Week: 46
    19-November-2010
    20-November-2010
    21-November-2010
    
    11 rows selected.
    
    SQL>
    
  • Update resulted today in count of the number of messages in different folders disappear, except new

    I was asked to update to Thunderbird and did, when I came back later in the afternoon, the messages were always in each folder (sent for example), but the count of the number of messages in each category had disappeared.

    What about the small thing square on the line with the name above the part of the file. He has options for/unread and size

  • How do fill you in marked with red, green or yellow, and counting also the boxes ticked in the column?

    I am working on a form with three columns, one column is "Yes" = green, a column is 'No' = red and the other "current" yellow =.

    The goal is to have control of the "NO" box when chosen turns red background. The other goal is also count all the boxes 'NO' in the column.

    Currently, all the checkbox values '1' so I can count.

    Ok. In this case, you can use something like this as action MouseUp-check boxes:

    if (event.target.value=="1") event.target.fillColor = color.green;
    else if (event.target.value=="2") event.target.fillColor = color.red;
    else if (event.target.value=="3") event.target.fillColor = color.yellow;
    else event.target.fillColor = color.white;
    

    To count all the answers not use this code as the calculation script custom of the text field where you want to display this number:

    var total = 0;
    for (var i=1; i<=9; i++) {
        if (this.getField("standard_"+i).valueAsString=="2") total++;
    }
    event.value = total;
    
  • REQ: script to calculate the number of months

    Looking for a script that will calculate the number of months between 2 dates (to 2 decimal points)

    or if there is a way to make a calculation of the number of months

    for example: if I go to google and say 75 days - months, it returns a value of 2.46

    That's what I'm looking for

    If anyone can help?

    with a calculation of date or number calculation?

    I tried # days / 365 x 12 but there is no decimal places.  right guard rounded up/down

    As mentioned in a month, the days are not constant throughout the year and change formula 28-31 days. How are you calculating the decimal value of the month?

    A year has 365 days, if she did then there would be no need for leap years and centuries jump.

    Calculation of a variable with the result of a calculation method is set to decimal.

    cDateFormat = "d-mmm-yyyy";
    var cStartDate = "January 1, 2000;
    var oStartDate = util.scand (cDateFormat, cStartDate);
    oStartDate.setHours (0, 0, 0, 000);
    var cEndDate = "January 15, 2000;
    var oEndDate = util.scand (cDateFormat, cEndDate);
    oEndDate.setHours (0, 0, 0, 000);
    nDiff var = oEndDate.getTime () - oStartDate.getTime ();
    Console.println ("end date:" + cEndDate);
    Console.println ("start date:"+ cStartDate ");
    Console.println ("difference in milliseconds:" + nDiff);
    Console.println ("difference in seconds:" + nDiff/1000);
    Console.println ("difference in minutes:" + nDiff / (1000 * 60));
    Console.println ("difference in hours:" + nDiff / (1000 * 60 * 60));
    Console.println ("difference in days:" + nDiff / (1000 * 60 * 60 * 24));
    Console.println ("difference in weeks:" + nDiff / (1000 * 60 * 60 * 24 * 7));
    Console.println ("difference over the years:" + nDiff / (1000 * 60 * 60 * 24 * 365.2524));
    Console.println ("difference in months:" + nDiff / ((1000 * 60 * 60 * 24 * 365.2524) / 12));  12 months in a year;

    End date: January 15, 2000
    Start date: January 1, 2000
    Difference in milliseconds: 1209600000
    Difference in seconds: 1209600
    Difference in minutes: 20160
    Difference in hours: 336
    Difference in days: 14
    Difference of weeks: 2
    Difference in years: 0.0383296591617194
    Difference in months: 0.45995590994063273

    Several turncate the decimal values scirpts because keeping them may not meet the need of specific calculation. You know that there are methods to roud until the next iniger, round.5 to the top and turnacate to the lower intiger.

    According to the date of departure, the values may be different:

    For a start date of February 1, 2000, 75 days would be 1,810 months but for a start date of 1 February 2001 75 days becomes 1,838 since the number of days of changes of February 29 to 28 and the number of days for the month of fractions varies from 26 to 27.

  • Get the number of months between the dates.

    Hi I need to get the exact number of months between the dates. So if I'm Sysdate - to_date(31-JAN-2011) I should get something like 8.4 months. Months_between function doesn't quite give me what I need. Is it possible that I can do this?

    876056 wrote:
    Hi I need to get the exact number of months between the dates. So if I'm Sysdate - to_date(31-JAN-2011) I should get something like 8.4 months. Months_between function doesn't quite give me what I need. Is it possible that I can do this?

    I don't see how you get 8.4 months. The counted months are February, March, April, may, June, July, August and, as of today, 9 and change the days of September. Unless I forgot the lessons of counting, I learned in kndergarten is 7 full months and a bit.

    Maybe you want something like:

    SQL> select months_between(Sysdate, to_date('01-JAN-2011', 'dd-mon-yyyy')) mb,
      2         (Sysdate - to_date('01-JAN-2011', 'dd-mon-yyyy'))/30 div30
      3  from dual;
    
            MB      DIV30
    ---------- ----------
    8.27800142 8.38726813
    

    If you get the form date a table, you can use trunc (date_column, 'mm') at the date of the first day of the month.

    John

  • Compilation error in tables starting with "number of months".

    Our project currently uses two entities: global (the family) and the person.

    I'm unable to compile a document when using a variable number that begins with "the number of months the person...". "in a table. For example, I tried to use this table to set the period of time to 0 in case "the person" does not request specific supplement type:

    --------------------------------------------------------------------------------------------------------------------------------------------------------------------
    Conclusion of the table:
    the number of months that the person will receive the supplement for assistance with associated transportation costs and visitors who attend the related program of employment

    Return value:
    the number of months the person to receive further assistance for transport and attendance costs to participate in the program related to employment

    If the following attribute is set to True:
    Supplement of the person is using to transport costs and traffic associated with participating in the program related to employment

    Otherwise:
    * 0 *
    --------------------------------------------------------------------------------------------------------------------------------------------------------------------


    The error I'll be back when you try to compile said: error after "number of". Found: «months that the person has applied to receive a supplement...» ». Expected: Unable to find a relationship of belonging to the entity "the person".

    However, I am able to compile the same attribute when it is written in the typical word format.



    I found two workaround solutions:

    (1) I cannot change variables numbers as follows: "the requested person several months to receive a supplement...» »
    (2) I can compile and generate if I write the attribute at the global level: "the number of moths the supplement for assistance... will be issued".

    Is anyone know why I get the above error?



    Thank you
    Ashley

    Have a variable whose text begins by "the number of ' is not a problem. I think that your problem here, is that the variables have not been declared.

    I just tried the table you have described above. When all variables are declared, they compile not very well. When one or both of the variables have not been reported, I got an error message similar to the one you have seen.

    See you soon,.
    Jasmine

  • Select the number of months (NULL and non-null separated)

    -Table_1
    -------------

    create table_1
    (
    Arrival_Date DATE
    Counter_seq number (*) not null,
    Exclusion_type varchar2 (10)
    )

    -INSERTION
    -------------

    INSERT INTO 'DW_DOCA '. "' TABLE_1 ' ('ARRIVAL_DATE', 'COUNTER_SEQ', 'EXCLUSION_TYPE') VALUES (TO_DATE('12-DEC-2009', 'dd-Mon-yyyy HH:MI:SS AM'), 1,");
    INSERT INTO 'DW_DOCA '. "' TABLE_1 ' ('ARRIVAL_DATE', 'COUNTER_SEQ', 'EXCLUSION_TYPE') VALUES (TO_DATE('12-JAN-2010', 'dd-Mon-yyyy HH:MI:SS AM'), 2, 'PAW');
    INSERT INTO 'DW_DOCA '. "' TABLE_1 ' ('ARRIVAL_DATE', 'COUNTER_SEQ', 'EXCLUSION_TYPE') VALUES (TO_DATE('28-DEC-2009', 'dd-Mon-yyyy HH:MI:SS AM'), 3, 'HAN');
    INSERT INTO 'DW_DOCA '. "' TABLE_1 ' ('ARRIVAL_DATE', 'COUNTER_SEQ', 'EXCLUSION_TYPE') VALUES (TO_DATE('12-FEB-2010', 'dd-Mon-yyyy HH:MI:SS AM'), 4,");
    INSERT INTO 'DW_DOCA '. "' TABLE_1 ' ('ARRIVAL_DATE', 'COUNTER_SEQ', 'EXCLUSION_TYPE') VALUES (TO_DATE('12-JAN-2010', 'dd-Mon-yyyy HH:MI:SS AM'), 5,"LUG");
    INSERT INTO 'DW_DOCA '. "' TABLE_1 ' ('ARRIVAL_DATE', 'COUNTER_SEQ', 'EXCLUSION_TYPE') VALUES (TO_DATE('28-JAN-2009', 'dd-Mon-yyyy HH:MI:SS AM'), 6, 'HAN');
    INSERT INTO 'DW_DOCA '. "' TABLE_1 ' ('ARRIVAL_DATE', 'COUNTER_SEQ', 'EXCLUSION_TYPE') VALUES (TO_DATE('12-DEC-2009', 'dd-Mon-yyyy HH:MI:SS AM'), 7,");
    INSERT INTO 'DW_DOCA '. "' TABLE_1 ' ('ARRIVAL_DATE', 'COUNTER_SEQ', 'EXCLUSION_TYPE') VALUES (TO_DATE('12-FEB-2010', 'dd-Mon-yyyy HH:MI:SS AM'), 8, 'PAW');
    INSERT INTO 'DW_DOCA '. "' TABLE_1 ' ('ARRIVAL_DATE', 'COUNTER_SEQ', 'EXCLUSION_TYPE') VALUES (TO_DATE('28-JAN-2010', 'dd-Mon-yyyy HH:MI:SS AM'), 9, 'HAN');
    INSERT INTO 'DW_DOCA '. "' TABLE_1 ' ('ARRIVAL_DATE', 'COUNTER_SEQ', 'EXCLUSION_TYPE') VALUES (TO_DATE('12-FEB-2010', 'dd-Mon-yyyy HH:MI:SS AM'), 10,");
    INSERT INTO 'DW_DOCA '. "' TABLE_1 ' ('ARRIVAL_DATE', 'COUNTER_SEQ', 'EXCLUSION_TYPE') VALUES (TO_DATE('12-DEC-2010', 'dd-Mon-yyyy HH:MI:SS AM'), 11, 'PAW');
    INSERT INTO 'DW_DOCA '. "' TABLE_1 ' ('ARRIVAL_DATE', 'COUNTER_SEQ', 'EXCLUSION_TYPE') VALUES (TO_DATE('28-JAN-2010', 'dd-Mon-yyyy HH:MI:SS AM'), 12, 'HAN');
    INSERT INTO 'DW_DOCA '. "' TABLE_1 ' ('ARRIVAL_DATE', 'COUNTER_SEQ', 'EXCLUSION_TYPE') VALUES (TO_DATE('12-DEC-2009', 'dd-Mon-yyyy HH:MI:SS AM'), 13,");
    INSERT INTO 'DW_DOCA '. "' TABLE_1 ' ('ARRIVAL_DATE', 'COUNTER_SEQ', 'EXCLUSION_TYPE') VALUES (TO_DATE('12-FEB-2010', 'dd-Mon-yyyy HH:MI:SS AM'), 14,"LUG");
    INSERT INTO 'DW_DOCA '. "' TABLE_1 ' ('ARRIVAL_DATE', 'COUNTER_SEQ', 'EXCLUSION_TYPE') VALUES (TO_DATE('28-JAN-2010', 'dd-Mon-yyyy HH:MI:SS AM'), 15,");
    INSERT INTO 'DW_DOCA '. "' TABLE_1 ' ('ARRIVAL_DATE', 'COUNTER_SEQ', 'EXCLUSION_TYPE') VALUES (TO_DATE('12-FEB-2010', 'dd-Mon-yyyy HH:MI:SS AM'), 16,"LUG");
    INSERT INTO 'DW_DOCA '. "' TABLE_1 ' ('ARRIVAL_DATE', 'COUNTER_SEQ', 'EXCLUSION_TYPE') VALUES (TO_DATE('12-JAN-2010', 'dd-Mon-yyyy HH:MI:SS AM'), 17,");
    INSERT INTO 'DW_DOCA '. "' TABLE_1 ' ('ARRIVAL_DATE', 'COUNTER_SEQ', 'EXCLUSION_TYPE') VALUES (TO_DATE('28-JAN-2010', 'dd-Mon-yyyy HH:MI:SS AM'), 18,");
    INSERT INTO 'DW_DOCA '. "' TABLE_1 ' ('ARRIVAL_DATE', 'COUNTER_SEQ', 'EXCLUSION_TYPE') VALUES (TO_DATE('12-DEC-2009', 'dd-Mon-yyyy HH:MI:SS AM'), 19, 'HAN');
    INSERT INTO 'DW_DOCA '. "' TABLE_1 ' ('ARRIVAL_DATE', 'COUNTER_SEQ', 'EXCLUSION_TYPE') VALUES (TO_DATE('12-DEC-2009', 'dd-Mon-yyyy HH:MI:SS AM'), 20,");
    INSERT INTO 'DW_DOCA '. "' TABLE_1 ' ('ARRIVAL_DATE', 'COUNTER_SEQ', 'EXCLUSION_TYPE') VALUES (TO_DATE('28-FEB-2010', 'dd-Mon-yyyy HH:MI:SS AM'), 21,"LUG");
    INSERT INTO 'DW_DOCA '. "' TABLE_1 ' ('ARRIVAL_DATE', 'COUNTER_SEQ', 'EXCLUSION_TYPE') VALUES (TO_DATE('12-JAN-2010', 'dd-Mon-yyyy HH:MI:SS AM'), 22,"LUG");
    INSERT INTO 'DW_DOCA '. "' TABLE_1 ' ('ARRIVAL_DATE', 'COUNTER_SEQ', 'EXCLUSION_TYPE') VALUES (TO_DATE('12-DEC-2009', 'dd-Mon-yyyy HH:MI:SS AM'), 23,"HAN");
    INSERT INTO 'DW_DOCA '. "' TABLE_1 ' ('ARRIVAL_DATE', 'COUNTER_SEQ', 'EXCLUSION_TYPE') VALUES (TO_DATE('28-JAN-2010', 'dd-Mon-yyyy HH:MI:SS AM'), 24,");
    INSERT INTO 'DW_DOCA '. "' TABLE_1 ' ('ARRIVAL_DATE', 'COUNTER_SEQ', 'EXCLUSION_TYPE') VALUES (TO_DATE('12-FEB-2010', 'dd-Mon-yyyy HH:MI:SS AM'), 25,");
    INSERT INTO 'DW_DOCA '. "' TABLE_1 ' ('ARRIVAL_DATE', 'COUNTER_SEQ', 'EXCLUSION_TYPE') VALUES (TO_DATE('28-DEC-2010', 'dd-Mon-yyyy HH:MI:SS AM'), 26,"LUG");
    INSERT INTO 'DW_DOCA '. "' TABLE_1 ' ('ARRIVAL_DATE', 'COUNTER_SEQ', 'EXCLUSION_TYPE') VALUES (TO_DATE('12-FEB-2010', 'dd-Mon-yyyy HH:MI:SS AM'), 27,");


    -SELECT THE NUMBER OF MONTHS
    --------------------------------------

    SELECT EXCLUSION_TYPE,
    County (decode (to_char (ARRIVAL_DATE, 'MON-YYYY'), "DEC-2009", COUNTER_SEQ ")) dec09,.
    County (decode (to_char (ARRIVAL_DATE, ' MON-YYYY ""), "JAN-2010", COUNTER_SEQ ")) Jan10.
    County (decode (to_char (ARRIVAL_DATE, 'MON-YYYY'), ' Feb-2010 ", COUNTER_SEQ")) Feb10
    FROM TABLE_1
    EXCLUSION_TYPE GROUP;


    -CHOOSE IT ABOVE RETURENS: -.
    ------------------------------------------------


    EXCLUSION_ DEC09 JAN10 FEV10
    4 4 4
    0 3 4 LEG
    HAN 3 2 0


    My question is, I need to select a month ruturning one row of NULL values and a line of values not null. Like that so all right: -.

    EXCLUSION_ DEC09 JAN10 FEV10
    Exclusion_Type 4 4 4 NULL
    Exclusion_Type Not null 3 5 4

    The ideas people?

    Published by: Deeds_2001 on November 16, 2010 12:47 AM
    SQL> SELECT DECODE(exclusion_type,NULL,'NULL','NOT NULL') exclusion_type,
      2  COUNT(DECODE(TO_CHAR(arrival_date, 'MON-YYYY'), 'DEC-2009', counter_seq)) Dec09,
      3  COUNT(DECODE(TO_CHAR(arrival_date, 'MON-YYYY'), 'JAN-2010', counter_seq)) Jan10,
      4  COUNT(DECODE(TO_CHAR(arrival_date, 'MON-YYYY'), 'FEB-2010', counter_seq)) Feb10
      5  FROM table_1
      6  GROUP BY DECODE(exclusion_type,NULL,'NULL','NOT NULL');
    
    EXCLUSIO      DEC09      JAN10      FEB10
    -------- ---------- ---------- ----------
    NULL              4          4          4
    NOT NULL          3          5          4
    
    SQL> 
    
  • 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...)

  • Can Notes show the number of records with each folder?

    Can Notes show the number of records with each folder?

    No it can't. It would be nice tho.

  • Need to disable CGI, I have two-factor authentication, but I don't have the phone number or device with me. What can I do?

    Need to disable CGI, I have two-factor authentication, but I don't have the phone number or device with me. What can I do?

    For Apple ID - Apple Support two-factor authentication

    If I can not connect, how I again to access my account?

    If you can't sign in, reset your password, or receive verification codes, you can account recovery application to restore access to your account. Account recovery is an automatic process designed to help you back into your account as soon as possible while denying access to anyone who might be impersonating you. It may take a few days - or more - depending on the specific account information, you provide to verify your identity.

    It will be your option. If you try to find an iPhone with locking Activation that you don't remember the password, you can remove the account from the iPhone with the help of Apple's Support with the receipt of the initial purchase of the iPhone as a way to prove that you are the real owner of this iPhone.

  • My iPhone with iOS 9.2.1 5s is deleting random contacts.  This happened for several months is not just with the last update of iOS.  Any suggestions?

    My iPhone with iOS 9.2.1 5s is deleting random contacts.  This happened for several months is not just with the last update of iOS.  It deletes recently used contacts and removes also from my iPad.  Any suggestions?

    That you synchronize your contacts with? A decision-making application supported on the computer, a Cloud Computing service?

Maybe you are looking for

  • HP officejet d155xi - need driver for windows 2003

    Hi all I need your help. I have a hp printer officejet d155xi and need to install it in the Windows 2003 operating system but, unfortunately, theres no driver available for Win 2003. Are you able to provide me with that. Your help is really appreciat

  • entered iCal disappeared from the iphone

    Last night all of my entries on my calendar I simply disappeared. I can still see them on my iPad. I use my calendar daily daily, if so very problematic, but also very strange that all and I mean all, inscriptions on iCal disappeared after being ther

  • My automatic updates Windows Vista do not work? Error: Windows can't check for updates

    original title: My automatic Windows Vista updates do not work? My automatic updates Windows Vista do not work? There is no error code, it just says "Windows can't check for updates. I tried to use the fix from microsoft, it would join in the other r

  • HP Elite 371f: Hp 371f Win7x64 recovery software

    Cannot access anything whatsoever. Ask for support of startup boot device or insert. Do you have a hard drive Wipe, where can get these disks. Model supplied with Windows 7 x 64 Home Premium preinstalled. Never had any original discs. Help me please.

  • Office, web pages, all display 90 degrees (laterally) HELP!

    don't know what happened, but everything is at 90 degrees off display. Can move the taskbar, but another everythng is always on the side