How to find out number of  years worked using sql

Hello,
How to find from a table which has hiredate and should return number of years worked with range like 0-5, 5-10,10-15 etc.
Any help is highly appreciated.
Thanks

I think this query can solve your issue
SELECT CASE yeared,COUNT(CASE) FROM
SELECT
CASE
WHEN MONTHS_BETWEEN(SYSDATE,hiredate)/12 <=5 THEN '0-5'
WHEN MONTHS_BETWEEN(SYSDATE,hiredate)/12 > 5 AND MONTHS_BETWEEN(SYSDATE,hiredate)/12 <=10 THEN '5-10'
WHEN MONTHS_BETWEEN(SYSDATE,hiredate)/12 > 10 AND MONTHS_BETWEEN(SYSDATE,hiredate)/12 <=15 THEN '10-15'
WHEN MONTHS_BETWEEN(SYSDATE,hiredate)/12 > 15 AND MONTHS_BETWEEN(SYSDATE,hiredate)/12 <=20 THEN '15-20'
WHEN MONTHS_BETWEEN(SYSDATE,hiredate)/12 > 20 AND MONTHS_BETWEEN(SYSDATE,hiredate)/12 <=25 THEN '20-25'
WHEN MONTHS_BETWEEN(SYSDATE,hiredate)/12 > 25 AND MONTHS_BETWEEN(SYSDATE,hiredate)/12 <=30 THEN '25-30'
ELSE '>=30'
END CASE
FROM scott.emp )
GROUP BY CASE
Regards.

Similar Messages

  • How to find out number of background work processe available in the system?

    Hi All,
    I have a FM that triggers a background job using JOB_OPEN, ABAP_SUBMIT and JOB_CLOSE. But the problem is if there are no background work processes available at that moment, it does not return error. Not sure whether the job is even scheduled!
    Is there a way to find out if there are any background work processes available in the system? I know a FM SPBT_INITIALIZE which gives info about dialog work processes. Is there any other FM similar to this which gives info about background wp??
    Regards,
    Shailesh

    your Job will remain in a queue by message handler. once workprocess is free, your job gets scheduled
    by the way, you can use the functionality used in FM TH_DISPLAY_WORKPROCESS_LIST to read the workprocesses
    the command which gets you the workprocess is:
    CALL 'ThWpInfo' ID 'OPCODE' FIELD OPCODE_WP_LIST
                      ID 'TAB' FIELD LIST_STATE_WPLST-TABL
                      ID 'CPU' FIELD LIST_STATE_WPLST-CPU.
    check how its written in include LSDEBF01, form SET_LIST_WPLST
    Edited by: Soumyaprakash Mishra on Dec 12, 2011 12:17 PM

  • How to find out that particular structure is used in which tables

    Hello Friends,
    Most of the times through techinal information we come to know the table name for a particular field.And in se16 when i give that table name than system says its structure and not the table.So in se11 when i give that structure name in database table field, its shows all the field in that structure, but not the data stored in that field.
    So my question is how to find out that particular structure is used in which tables,so that i can view data stored in that structure?
    Thanking you guys in advance.
    Regards,
    Jitendra

    Dear,
    When you click on the technical information it will give the structure name and field, double click on the structure and it will take you the display structure screen, there you will have the where-used List icon (Ctrl + Shift + F3) at the top , click on that and it will show the options, select Database tables and execute, it will give the tables related to the structure, you can explore the list of tables and find where your required field is stored in them.
    Thanks & Regards,
    Vijaya Bhaskar A

  • How to find out the Non Partitioned Tables used 2Gb on oracle

    Hi team
    how to find out the Non Partitioned Tables used > 2Gb on oracle where not is sys & system
    regards

    heres 1 I made earlier
    set pagesize 999
    set linesize 132
    col owner format a25
    col segment_name format a60
    select owner,segment_name,segment_type,(bytes/1024/1024)"MB size"
    from dba_segments
    where owner not in ('SYS','SYSTEM','XDB','MDSYS','SYSMAN') -- edit for taste
    and segment_type = 'TABLE'
    having (bytes/1024/1024) > 2000
    group by bytes, segment_Type, segment_name, owner
    order by 4 asc

  • How to find out  number of includes for a given program dynamically

    Hi all
    I have a requirement in which, I have to find out  number of includes and their names for a given  user defined program dynamically
    if u know the answer pls let me know
    Thanks in advance
    Devi

    Hi rama,
    1. use this FM - RS_GET_ALL_INCLUDES_FOR_PRTAB
    regards,
    amit m .

  • How to find out Number of entries in a Huge Table?

    Hi,
    I would like to know Number of entries in table DFKKOP. when i try to get it through se16, it takes more than 10 minutes in dialogue process so a time out occurs. is there any way to find out number of entries in the table Apart from creating a program for that?
    Please guide me to the solution.
    Thanks,
    Lijo Joseph
    Message was edited by: Lijo Joseph Vazhappilly

    REPORT  YCHATEST                                .
    Data : begin of itab occurs 0.
            include structure tab512.
    data:end of itab.
    data : v_count like sy-index,
           tabname like X030L-TABNAME value 'DFKKOP'.
    CALL FUNCTION 'RFC_GET_TABLE_ENTRIES'
      EXPORTING
        table_name              = tabname
    IMPORTING
       NUMBER_OF_ENTRIES       = v_count
    tables
       entries                 = itab.
    write : v_count.
    Message was edited by: Sekhar

  • How to find out which queries are being used ?

    We have a number of InfoSet Queries which the users are calling from SQ00. Some of them are very old.
    I would like to find out which queries are being used, so we can have the idle queries decommissioned.
    How can this be done ?
    Best regards,
    Peter

    Hi,
    It's been a while since I've done this but one method is to use ST03N & look for the execution of programs with an AQ* prefix.  The general structure is AQZZ/<query user group><query name>.
    You could probably get the same info from the audit log but I've not checked that.
    Cheers,

  • How to find out what are the interfaces used for Job and Job Codes

    HI All,
    I just wanted to know how do we find out what are the interfaces used for Job and Job codes .
    Thanks In Advance
    Sunny

    Hi,
    Here is an idea for your request.
    Basically you can create a simple query on multiprovider 0TCT_MC01.
    Filter: you can use a variable for restriction of time ( calday, or calmonth) since you should be interested for a time period.
    Choose following characters into your objects:
    InfoProvider ( 0TCTIFPROV )  - you can create a variable for choosing infoprovider before query runs.
    *Tp.[Type of BI Application Object] 0TCTBISOTYP  = filter this with 'QUERY' or whatever your need is.
    *BI Application Object 0TCTBISBOBJ,  ( this will give you the name of the queries)
    In key figures choose,  Count for BI Appl. (0TCTWTCOUNT).
    (number for query run)
    Create a condition , for top 20.
    Hope this helps.
    Derya

  • How to find out portlet instance type without using PortletInstanceInternal

    Does anyone know how to find out the instance type of a portlet using the API? The instance type corresponds to INSTANCE_TYPE column in PF_PORTLET INSTANCE table.

    Does anyone know how to find out the instance type of a portlet using the API? The instance type corresponds to INSTANCE_TYPE column in PF_PORTLET INSTANCE table.

  • How to find out number of concurrent users  connectd to a site?

    I would like to find out the number of concurrent users on my site. What is the best way to do it?
    This is how I implement it currently:
    I have a HashSet object in the session. whenever a user visits the page, i added the user's sessionID to the HashSet. But when a user leaves my page, it won't inform my jsp pages. The only thing I can do now is whenever I add a new sessionID, I loop through the HashSet and check to see which sessionID is invalid or inactive, then remove the it. Does a user session becomes invalid immediately when the user leaves the page, or it has to wait till it times out?
    Are there any other more efficient ways of doing it?

    Look at HttpSessionBindingListener. That will let you do what you want to, correctly.
    User session will time not. If it were to become invalid immediately, it won't be called a "session" would it?

  • How to find out whether I am working on the right instance?

    Hi All
    I want to find out from Oracle Apps i.e., Front end the following:
    Whether the instance I am working on currently is the same one or restored from a backup. I will not be able to find out the difference immediately as the changes between the current instance and backup instance are very few and dispersed but at the same time critical to the system.
    How can I find out from the front end whether the instance is same as I was working yesterday assuming I am the only user?
    Thanks in Advance for any help.
    Regards
    Rahman

    Hi,
    as the changes between the current instance and backup instance are very few and dispersed but at the same time critical to the system.I believe there is no way to find out unless you check and see those changes (before/after the restore).
    Regards,
    Hussein

  • How to find out number of bookmarks created?

    Is there any way to find out how many bookmarks have been created by users? I can see a list of all bookmarks under RSA1, Reporting Agent, Bookmarks, but I can't see a way to export that list or show a total.

    Thanks, that table has a list of all bookmarks.
    It seems like it only stores the last time a bookmark was accessed though...for example, if someone opens a bookmark 10 times, there would still just be one record for that bookmark.

  • How to find out the execution time of a sql inside a function

    Hi All,
    I am writing one function. There is only one IN parameter. In that parameter, i will pass one SQL select statement. And I want the function to return the exact execution time of that SQL statement.
    CREATE OR REPLACE FUNCTION function_name (p_sql IN VARCHAR2)
    RETURN NUMBER
    IS
    exec_time NUMBER;
    BEGIN
    --Calculate the execution time for the incoming sql statement.
    RETURN exec_time;
    END function_name;
    /

    Please note that wrapping query in a "SELECT COUNT(*) FROM (<query>)" doesn't necessarily reflect the execution time of the stand-alone query because the optimizer is smart and might choose a completely different execution plan for that query.
    A simple test case shows the potential difference of work performed by the database:
    Oracle Database 10g Express Edition Release 10.2.0.1.0 - Production
    Session altered.
    SQL>
    SQL> drop table count_test purge;
    Table dropped.
    Elapsed: 00:00:00.17
    SQL>
    SQL> create table count_test as select * from all_objects;
    Table created.
    Elapsed: 00:00:02.56
    SQL>
    SQL> alter table count_test add constraint pk_count_test primary key (object_id)
    Table altered.
    Elapsed: 00:00:00.04
    SQL>
    SQL> exec dbms_stats.gather_table_stats(ownname=>null, tabname=>'COUNT_TEST')
    PL/SQL procedure successfully completed.
    Elapsed: 00:00:00.29
    SQL>
    SQL> set autotrace traceonly
    SQL>
    SQL> select * from count_test;
    5326 rows selected.
    Elapsed: 00:00:00.10
    Execution Plan
    Plan hash value: 3690877688
    | Id  | Operation         | Name       | Rows  | Bytes | Cost (%CPU)| Time     |
    |   0 | SELECT STATEMENT  |            |  5326 |   431K|    23   (5)| 00:00:01 |
    |   1 |  TABLE ACCESS FULL| COUNT_TEST |  5326 |   431K|    23   (5)| 00:00:01 |
    Statistics
              1  recursive calls
              0  db block gets
            419  consistent gets
              0  physical reads
              0  redo size
         242637  bytes sent via SQL*Net to client
           4285  bytes received via SQL*Net from client
            357  SQL*Net roundtrips to/from client
              0  sorts (memory)
              0  sorts (disk)
           5326  rows processed
    SQL>
    SQL> select count(*) from (select * from count_test);
    Elapsed: 00:00:00.00
    Execution Plan
    Plan hash value: 572193338
    | Id  | Operation             | Name          | Rows  | Cost (%CPU)| Time     |
    |   0 | SELECT STATEMENT      |               |     1 |     5   (0)| 00:00:01 |
    |   1 |  SORT AGGREGATE       |               |     1 |            |          |
    |   2 |   INDEX FAST FULL SCAN| PK_COUNT_TEST |  5326 |     5   (0)| 00:00:01 |
    Statistics
              1  recursive calls
              0  db block gets
             16  consistent gets
              0  physical reads
              0  redo size
            412  bytes sent via SQL*Net to client
            380  bytes received via SQL*Net from client
              2  SQL*Net roundtrips to/from client
              0  sorts (memory)
              0  sorts (disk)
              1  rows processed
    SQL>As you can see the number of blocks processed (consistent gets) is quite different. You need to actually fetch all records, e.g. using a PL/SQL block on the server to find out how long it takes to process the query, but that's not that easy if you want to have an arbitrary query string as input.
    Regards,
    Randolf
    Oracle related stuff blog:
    http://oracle-randolf.blogspot.com/
    SQLTools++ for Oracle:
    http://www.sqltools-plusplus.org:7676/
    http://sourceforge.net/projects/sqlt-pp/

  • How to find out which formulas have been used in sales orders of a period

    Hi Experts,
    I am trying to find out how much my users actually use the formula and average pricing. Therefore, I am trying to build a quick viewer by relating tables. In order to use the F&A pricing, they use one particular condition type ZFA1. By linking tables vbak and KONV via KNUMV, I can see in which orders they have used ZFA1, but I also want to find out which Formula they have chosen from the repository. As this is visible for the user from the sales order, there should be a table that stores it, but I cannot find it. Does someone know the table and can help me on this topic?
    If you provide the solution, I will definitely give you the reward points. Thank you in advance!
    Greetings
    Petra

    Hi Petra,
    Please try to check the table OICQ7 with KNUMV from VBAK.
    KR,
    Sergey

  • How to find out the web/app server used by OBIEE and OBIEE HomePath (Urgent

    Hi All ,
    I have two questions
    1) I wanted to know the OBIEE home path if it is installed on the some other machine (Client's Machine).
    I wanted to update the .css files present on the machine, but before updating the file i should know the home path, to reach the desired .css file and update accordingly. I dont know where they have installed OBIEE.By default OBIEE home is (c:\) but if the user has selected some other drive then, how we can find the OBIEE Home path?
    I have the access to the machine.
    2) The path of the CSS files depends on the web server used by OBIEE.
    When IIS web server is used, the CSS files in OracleBI_HOME\web\app\res directory
    when OC4J is used, the CSS files in OracleBI_HOME\oc4j_bi\j2ee\home\applications\analytics\analytics\res
    so inorder to update i must know which server is being used.
    Is there any way to find out which web application server is installed on the clients machine?
    Thanks in advance.!!!!!

    Please see responses to your first posting here: OBI EE Home Path

Maybe you are looking for

  • Printing to shared windows printer canon bj-200e

    Hi, Has anyone had any success with or know how to set up printing to a canon bj-200e which is shared on a windows XP machine? I've gone through as many of the directions as I could find but haven't had much luck. There doesn't appear to be any OS X

  • I get error message When I try to set admin password on Pixma MG2922.

    When I try to set my Admin password on my Pixma MG2922. I get an error message in the last box when I confirm the passwrd. "Passord entered is invalid" . I have tried everything. Password was never changed from Default. What is the Default password?

  • Trying to extend a second wireless network...

    Hello, I am trying to extend a secondary wireless network in my home. I have a **** wireless n router, 2 Airport Expresses and a Time Capsule. All Apple components are wireless n. I want to have a network being broadcast by the ****, a second network

  • Sun Java System Application Server for Mac OS X ?

    hi everybody. does anybody know if (any given date ?) sun is planning to offer a distribution of its sun java system application server for mac os x ? or even better: any ideas on how to install a currently available version on mac os x 10.4 ? the li

  • JScrollPanel basic problem

    Hi, would be grateful if someone could help out with this basic problem: I'm using a JTextArea that displays additional text added using the append() method in a java2 1.4 program, but I need it to automatically scroll down to show the latest line of