How to get every month with SQL query?

Hello world
I want to display every month (Jan-Dec) in the 1st column and their leaders in the 2nd column, but that there is no record in JAN, Feb and March, while they do not come to the top.
Can someone please help me get JAN, FEB etc with leaders like 0?

I know it's possible with the NVL function, but I don't know where to put it.
I'm really grateful for help you.
Thanks in advance.
I use oracle 10g on Windows XP.

[code]

SELECT ".

CASE

WHEN b.mon = '01' THEN 'JAN' WHEN b.mon = '02' THEN 'FEB' WHEN b.mon = '03' AND 'MAR '.

WHEN b.mon = '04' THEN "APR" b.mon = WHEN '05' CAN '' MAY '' WHEN b.mon = '06' THEN 'JUN '.

WHEN b.mon = '07' THEN 'JUL' WHEN b.mon = '08' and THEN 'AUG' WHEN b.mon = '09' AND 'MS '.

WHEN b.mon = '10' and 'OCT', THEN WHEN b.mon = '11' and THEN 'NOV' WHEN b.mon = '12' AND 'DEC '.

END of month

count (*) NTC

Of

(Con.fst_name SELECT first_name, con.last_name, usr.login, USER_ID,)

App.appl_src_cd Registration_Source, to_date(usr.created,'DD-MON-YY') Created_Date,

To_char(usr.created,'MM') Lun

of usr, con siebel.s_contact siebel.s_user, siebel. S_PER_PRTNRAPPL app

where con.par_row_id = usr.row_id

and app.row_id = con.row_id

and app.appl_src_cd = 'Siebel eService.

AND TO_CHAR (usr.created, 'YYYY') =: P415_YEAR

) b

B.mon group

order by 3 desc

[/ code]

Now get the output voltage...

MONTHCNT
APR4818
JUL4543
JUN4295
MAY4190
AUG541
MAR20

What Jan, Feb, March etc in there too with the County under the name of 0.

SELECT TO_CHAR (TO_DATE (b.mon, 'mm'), 'MY') month.

Count ()) - 1 cnt

DE)

Con.fst_name SELECT first_name,

con.last_name,

usr. Login, USER_ID,

App.appl_src_cd Registration_Source,

to_date(usr.created,'DD-mon-YY') Created_Date,

To_char(usr.created,'MM') Lun

OF siebel.s_user usr.

Con Siebel.S_CONTACT,

Siebel. S_PER_PRTNRAPPL app

WHERE con.par_row_id = usr.row_id

AND app.row_id = con.row_id

AND app.appl_src_cd = 'Siebel eService.

AND TO_CHAR (usr.created, 'YYYY') =: P415_YEAR

UNION ALL

SELECT null,

NULL,

NULL,

NULL,

NULL,

LPAD(Level,2,'0')

OF the double

CONNECT BY level<=>

) b

GROUP BY b.mon

ORDER BY DESC 3

SY.

Tags: Database

Similar Questions

  • How to get in touch with customer service?

    How to get in touch with customer service? Twice I had a cat and I would get an answer in the coming days. Never heard a thing! I need an invoice for my accounts but I can't download it. It is said: the customer service contact. But I chatted for 2 times, tried to call, they don't answer the phone. Where is the customer service!

    Hi Regine43b,

    Please visit the following link to get your monthly bill: http://helpx.adobe.com/x-productkb/policy-pricing/print-creative-cloud-receipt.html

    If in case still encounter you problems, please contact support @ https://helpx.adobe.com/contact

    Kind regards

    Sheena.

  • How to get children to tree per query

    Hai all

    I have design table like this:
    menu_id menu_parent
    A.............-
    B............. A
    B01... B
    B02... B

    So, I have a tree like this:
    A
    --B
    -B01
    -B02

    I wanted to ask you, how to get child of tree per query, if I select menu_id = B, so the query result is:

    menu_id
    B
    B01
    B02

    I hope you could help me.

    Thank you

    Published by: 934603 on May 15, 2012 23:52

    Welcome to the Ant.

    You can try this

    --Lets consider this as your table
    with my_menu
    as
    (
    select 'A' menu_id, null menu_parent from dual
    union all
    select 'B', 'A' from dual
    union all
    select 'B01', 'B' from dual
    union all
    select 'B02', 'B' from dual
    )
    -- end of sample table
    select level, menu_id
      from my_menu
     start with menu_id = 'B'
    connect by prior menu_id = menu_parent ;
    
  • Why if I pay every month with my VISA card I can't use the program? Said THAT THE TRIAL has EXPIRED? and I pay every month!

    Por that TR pago my a my con mi tarjeta VISA no puedo use el programa?  Me as EL PERIODO DE PRUEBA HA CADUCADO?

    Why if I pay every month with my VISA card I can't use the program? Said THAT THE TRIAL has EXPIRED? and I pay every month!

    Telefono del servicio customer service numbers support Adobe tecnica in todo el mundo y

    País/región Attention to the client
    Norteamérica
    EE. UU. There Canada 800-443-8158.
    Europa
    Austria 6950071855 3 option
    BELGICA 027 119 960 3 option
    Dinamarca + 45 38 322 914 option 3
    Irlanda + 353 (0) 1 242 1552 option 3
    Finlandia + 358 (0) 969 379 671 option 3
    Francia 01 71 23 01 96 option 3
    Alemania 6950071855 3 option
    Italia 02 6 968 2817 option 3
    Countries Bajos + 31 (0) 20 201 3331 option 3
    Noruega + 47 23 16 28 81 option 3
    España 900 810339 option 3
    Suecia + 46 (0) 858 536 692 option 3
    Suiza 18009581 3 option
    RU + 44 (0) 207 365 0733 option 3
    Asia/Pacífico
    Australia 1800 614 863
    China 58657700 010
    Hong Kong 30714922
    India 0124 4003810

    000 800 440 1751 Indonesia 001 803 447 361 on 03-5350-0407 Corea 02 563 2555 Malasia 1 300-80-0027 Nueva Zelanda 0 800 485 948 Filipinas 180014410440 Singapur 800-448-1642 Taiwan 0800-666-536 Tailandia 001 800 441 8813 Otro + 632 636 8450 Latinoamerica Argentina 0 800 444 0290 Brasil 0800 8921704 El Caribe 206-675-6100 Central America 206-675-6100 Chile 1230-020-0109
    206-675-6100 Colombia 01 800 5 1 80102
    206-675-6100 Costa Rica 0 800 011 0910
    206-675-6100 Mexico City 001 800 249 1039
    206-675-6100 Sudamérica 206-675-6100 Venezuela 206-675-6100 Africa South Africa + 44 (0) 20 7365 0733
  • How to get after effect with out having to pay permanently?

    How to get after effect with out having to pay permanently?

    http://www.Adobe.com/products/catalog/CS6._sl_id-contentfilter_sl_catalog_sl_software_sl_c reativesuite6.html

  • How do I get the data of "Regulatory BOM" Formulation with SQL query output

    Hello

    We would like to implement a State of BiPublisher that displays "Regulation BOM" (wording-> click on TAB Formulation on exit Popup-> TAB Composition) information table.

    How could get us this information with an SQL query?

    Thank you

    Annarosa

    Hi, given 'Regulatory BOM' output of the Formulation are more complicated than expected. Attached is an example. You can test and make the appropriate changes to your report.

  • Help with SQL Query (Subselects)

    Hello community,

    IAM a new Member in this forum. The first excuse my English, my native language is German.
    In my workplace, we have a great Orcle Database 11 g with 30 different tables for production control issues.
    I try to get a couple of different information from the database, so I started with SQL of the query, but for this problem, I wasn't able to write a query to work.

    In this case, I have 2 tables:
    Table 1:
    ID; ORDER_NR; DESCRIPTION; CREATE_DATE
    1; A500236; CLEAN HOUSE; 20/02/2012
    2; A623555; REPAIR CAR; 10/01/2012
    3; A866944; MAINTAIN EQUIPMENT; 11/02/2012

    Table 2:
    ID; ORDER_NR; WO_STEP; STEP_DATE; EMPLOYEE
    1; A500236; A; 21/02/2012; W0010
    2; A500239; F; 21/02/2012; W0010
    3; A500239; S; 22/02/2012; W0027
    4; A500239; R; 23/02/2012; H0034
    5; A500239; U; 25/02/2012; L0099
    6; A263555; A; 15/01/2012; G0009
    7; A263555; C; 17/01/2012; S0039
    5 V A263555; R; 18/01/2012; K0059
    9; A263555; U; 19/01/2012; A0048
    10; A866944; A; 13/02/2012; H0034
    11; A866944; B; 13/02/2012; L0035
    12; A866944; G; 17/02/2012; D0084
    13; A866944; U; 23/02/2012; S0039

    And the result of my query should look like this:
    ORDER_NR; DESCRIPTION; CREATE_DATE; A_STAT_AGE; R_STAT_AGE; U_STAT_AGE
    A500236; OWN HOME; 20/02/2012; 5; 3; 1
    A623555; REPAIR CAR; 01/10/2012; 42; 39; 38
    A866944; MAINTAIN EQUIPMENT; 11/02/2012; 15; 4; 3

    The age of my query result should be calculated from the date of the creation of the order.
    I would like to know 2 things, one is how old was the order when they reached this status, R and U.
    The second, that is, how long did you order remaining on A stat, R and U (and if possible all the others too)
    It can happen that not every order reaches every State, so he ca go directly from A you in this case I want to display a generic character in this row/column

    I hope you all know what I mean and what result to expect.

    Thanks for your help.

    Reinhard W.

    Hi, Reinhard,

    990524 wrote:
    Hi Frank,.

    I thank you for your professional response and excuse my non-professional way to clarify my question.
    I have now already read and understand how to ask good questions, but is there an easy an inexpensive way to run a database on my computer at home?

    You can download the Oracle database from this site. The Express edition is easier to install. It lacks a few features that the Enterprise edition (for example, partitioning table and safety of level line), but most of the things work in all editions of Oracle.
    All editions are free if you do not use them for Production applications. Of course, at this price (or lack thereof), you get Oracle support.

    I have already noticed that the syntax SQL for Oracle differ from other DBMSS.

    Yes and some features are different in different products.

    Your query works perfectly, thank you.

    Now I want to refine my (your) query, is there a way to display a range of day within 1 day? As 0.5 day to half a day between two State timestamp.

    Of course, you can do it. After the exact output desired of the sample data that I posted. If the sample data do not show what you need to do, then after a few different examples of data that makes.

    My table contains the Date and time in a row, I forgot to mention that.

    After a CREATE TABLE statement. I was guessing a lot of things that may be important. For example, I assumed you were using a DATE for date and time column. So it is only reasonable to do so, but maybe it's not what looks like at your table.

    I tried something like this:

    SYSDATE - MIN ( CASE
                        WHEN  t2.wo_step = 'A'
                  THEN  t2.step_date
              END
               ) AS Age_A
    

    But it gives me an error of arithmetic overflow and not die difference in the Date and time or days with decimal friction.

    There are only about 5.4 million possible days with DATEs of Oracle. Is only 7 digits and Oracle can treat approximately 39 numbers without overflow errors, so I don't see how this can happen if t2.step_date is really a DATE. This is an example of why you need to publish a CREATE TABLE statement.

  • How to get an array of SQL data

    Hello

    I need to get a say DBMS output output of a SQL SELECT query say * OF EMP in the form of a table (with borders and titles).

    Is this possible in Oracle to return a table with borders and titles?

    user13410062 wrote:

    Hi all

    I don't know what am I missing in my question, which is confusing. The only thing I'm looking for is invoking a procedure/function of TOAD/SQLPLUS that can turn a TABLE formatting based on a query (SELECT * from insert_table where insert_table is-)
    CREATE TABLE insert_table
    (
    Number of S_No
    Varchar2 (128) of the player.
    Number of Ranking_Points
    Country varchar2 (128)
    );
    Now the output is visible in the result of the query or DBMS_OUTPUT as

    >> > >

    S_NO PLAYERNAME RANKING_POINTS COUNTRY
    1 Rafael Nadal 12390 Spain
    2 Roger Federer 7965 Switzerland
    3 Novak Djokovic 7880 Serbia

    To add to what anton said...

    When you submit a SQL query to the database, the statement is executed and the data is returned to the calling program.  The database has no awareness of what this program is, or how this program can restore the data on the screen, and the database itself is not any output device to display data.

    Thus, the data can be returned to various programs for example

    SQL * Plus - a terminal/command line screen, which usually uses a font to fixed width and standard characterset

    TOAD - a windows based application that has a "data grid" to display the data, you get

    SQL * Developer - windows-based application

    Oracle APEX - one based on web front end that makes HTML given to it, or can take the data and rendered in the HTML form for you.

    PowerBuilder - an application environment that could choose to display the data in DataWindow, store the data in data warehouses, be an intermediary providing data as a web service or be rendered web pages with data, etc..

    .NET - like PowerBuilder, it might choose to make the data are however required.

    Java - like Powerbuilder and .NET, it might choose to make the data are however required.

    etc.

    Thus, each of these environment renders data on the screen but he wants and will do it in a style that suits.  Some methods that work in an environment do not work in another environment, for example, you could provide data with the tab character included in the data and SQL * Plus can restore data with tags in it, but something like TOAD, perhaps will not and displays a character box indicating an "unprintable" character etc..

    That's why you can't just ask a question say you want to provide a query and get a table with headings etc. displayed, because the table with headings etc. depends entirely on the final user interface until you choose to use.

  • How to get the result of the query?

    I'm looking to get output something like this...

    If a profile exists on the Pb, I need Exists in the colum

    PROFILE_A EXISTS

    PROFILE_B DOES NOT EXIST

    PROFILE_C EXISTS

    Select distinct profile

    decode (profile, "PASSWORD_PROFILE", "EXISTS", 'THERE is NO') 'STATUS '.

    of dba_profiles;

    How to get the above result? Anyone?

    In the first query, you can add any profile you want to check, and then try the below

    WITH qry1 AS (SELECT profile 'PROFILE_A' FROM dual

    UNION ALL

    SELECT "PROFILE_B" FROM double

    UNION ALL

    SELECT 'DEFAULT' double)

    SELECT the profile

    CASE WHEN EXISTS (SELECT 1 FROM dba_profiles dp

    WHERE dp.profile = q1.profile)

    THEN "EXISTS."

    OTHERWISE "NOT EXIST".

    The END as status

    OF qry1 q1;

    OUTPUT:-

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

    SQL > WITH qry1 AS (SELECT profile 'PROFILE_A' FROM dual

    2. ANY TRADE UNION

    3. SELECT 'PROFILE_B' FROM dual

    4 UNION ALL

    5. SELECT 'DEFAULT' double)

    6. SELECT profile,

    7 CASE WHEN EXISTS (SELECT 1 FROM dba_profiles dp

    8 WHERE dp.profile = q1.profile)

    9 THEN 'EXISTS '.

    10. OTHERWISE "NOT EXIST".

    11 FINISSENT AS status

    Qry1 q1 12;

    PROFILE STATUS

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

    PROFILE_A DOES NOT EXIST

    PROFILE_B DOES NOT EXIST

    DEFAULT VALUE IS

  • Help me with SQL Query to retrieve data from a view

    Hello Guru,

    I need help in my sql query.
    I use SQL TeraData.
    I want an Oracle result in the following form-

    Open tickets
    Open months failure / Repair Service s/o improvement request Total general
    2009-01-2 4 4 5 15
    2009-02 1 0 2 3 6
    2009-03 4 1 2 2 9
    Grand Total 7 5 8 10 30


    I wrote the query as where - TIME_PERIOD, RQST_TYPE_DM and DEMAND_SUMMARY_FCT are the points of view and I extract the data from the views only.

    Select NVL (CA. TIME_PERIOD. PERIOD_CD, 'Total') THAT year.
    COUNT (CASE WHEN CA. RQST_TYPE_DM. RQSTTYP_DESC Like '% of Break' THEN 1 END) as BreakFix
    COUNT (CASE WHEN CA. RQST_TYPE_DM. RQSTTYP_DESC as 'N/a', 1 END) by n/a
    COUNT (CASE WHEN CA. RQST_TYPE_DM. RQSTTYP_DESC as 'Improvement' THEN 1 END) accessories
    COUNT (CASE WHEN CA. RQST_TYPE_DM. RQSTTYP_DESC Like '% Service' THEN 1 END) as ServiceRequests
    COUNT (CA. RQST_TYPE_DM. RQSTTYP_DESC) AS grand_total
    FROM CA. TIME_PERIOD, CA. RQST_TYPE_DM, CA. DEMAND_SUMMARY_FCT
    WHERE (CA. DEMAND_SUMMARY_FCT. RQSTTYP_ID = CA. RQST_TYPE_DM. RQSTTYP_ID)
    AND (CASE
    WHEN CA. DEMAND_SUMMARY_FCT. MONTH_ID = CA. TIME_PERIOD. PERIOD_ID, 1
    WHEN {fn concat ({fn concat (SUBSTR (CA. TIME_PERIOD. {(PERIOD_CD, 3, 4),'-')}, SUBSTR (CA. TIME_PERIOD. PERIOD_CD, 7, 2))} BETWEEN ' 2009-01' AND ' 2009-03' THEN 1
    WHEN CA. DEMAND_SUMMARY_FCT. RQSTTYP_ID = '1' then 1
    END) = 1
    GROUP BY ROLLUP (CA. TIME_PERIOD. PERIOD_CD)

    After executing the query, I get the following error:
    3076: syntax Error: Data Type 'Time' does not match a defined Type name.
    :( Kindly help me with this and let me know where I'm wrong... Please.

    Messages indicates something wrong with your data... It would seem that the data does not match your format mask.

    Thus, the data or the format mask.

  • How to get the create view sql statement

    I have a technical problem

    There is a view in the database, for example "topstudentsview" and sql statement is ' select * student where scores > 90;

    My question is how to get the sql statement of the view. I want to get the sql statement in the topstudentsview

    Is the equivalent in MS Sql

    sp_helptext 'topstudentsview '.

    How in Oracle?

    Thank you

    user10182401 wrote:
    My question is how to get the sql statement of the view.

    Simple answer: use a tool. Almost every development tool will give you an option for this requirement.

    In Oracle SQL Developer (free), it's as simple as:

    Connect to the database with the user and click on "views".
    Select the appropriate view, and then click the SQL tab.

  • How to get these settings in sql developer

    According to this link, when I chose my lines in sql developer I don't get all the options illustrated in the screenshot of the binding,

    My sql developer is Version 3.2.20.09 64-bit windows, to use this options I need to make all the settings?

    http://www.thatjeffsmith.com/archive/2013/02/how-to-copy-only-column-headers-from-query-results-in-Oracle-SQL-Developer?

    When I select and click right make me only

    (a) in respect of grid
    (b) single record view
    (c) number of lines
    (d) fInd / highlight
    (e) export

    Once you have identified the column headers desired by highlighting one or more related data cells in the results grid, place your cursor on any column heading, and right-click for the shortcut menu shown in the blog of Jeff Smith.

  • How to achieve this using the sql query?

    Hello gurus,

    I have a table like this
    id    name
    1       a
    2       b
    3       c
    4       d
    5       e
    6       f
    7       g
    8       h
    9       i
    10     j
    11     k
    12     l
    13     m
    now my result should be like this
    id    name  id   name   id   name 
    1       a     6       f      11     k
    2       b     7       g     12     l
    3       c     8       h     13     m
    4       d     9       i
    5       e     10      j
    How to achieve by sql query?

    Thank you and best regards,
    friend

    Edited by: most wanted! February 22, 2012 05:55

    Hello

    Did you mean this:

    with a as
    (select 1 id ,'a' name from dual
    union all select 2 id ,'b' name from dual
    union all select 3 id ,'c' name from dual
    union all select 4 id ,'d' name from dual
    union all select 5 id ,'e' name from dual
    union all select 6 id ,'f' name from dual
    union all select 7 id ,'g' name from dual
    union all select 8 id ,'h' name from dual
    union all select 9 id ,'i' name from dual
    union all select 10 id ,'j' name from dual
    union all select 11 id ,'k' name from dual
    union all select 12 id ,'l' name from dual
    union all select 13 id ,'m' name from dual
    )
    
    select
      id_1
      ,name_1
      ,id_2
      ,name_2
      ,id_3
      ,name_3
    
    from
      (
      select
        id id_1
        ,name name_1
        ,lead(id,5) over (order by id) id_2
        ,lead(name,5) over (order by id) name_2
        ,lead(id,10) over (order by id)  id_3
        ,lead(name,10) over (order by id) name_3
        ,rownum r
      from
        a
      )
    where
      r <=5
    
    D_1                   NAME_1 ID_2                   NAME_2 ID_3                   NAME_3
    ---------------------- ------ ---------------------- ------ ---------------------- ------
    1                      a      6                      f      11                     k
    2                      b      7                      g      12                     l
    3                      c      8                      h      13                     m
    4                      d      9                      i
    5                      e      10                     j 
    

    Kind regards

    Peter

  • Need help with sql query involving distinct and County

    I have 2 tables and I want to get the number of specific names. Find the details below. It's hard to explain but I will try to provide as much detail as I can.

    Table A:
    ID of the SR
    1001 1
    1002 2
    2 1003
    1004 3


    Table B:
    Name of the key SrNew
    1 David 1001
    2 James 1002
    3 James 1002
    4 James 1003
    5 James 1004
    6 Mike 1004

    Result: I'm looking:
    Count names such as if the name appears for the same ID of Table A two times, and then only count 1.

    Name of County
    David 1
    James 2 (1002 and 1003 for the same ID (ID #2) so count as 1 for this and then 1 more for 1004 and ID 3)
    1 Mike


    I have following question:
    SELECT distinct (b.Name), a.ID
    FROM TableA, TableB b
    Where a.Sr = b.SrNew Group By b.Name, a.ID

    and as a result I get:
    ID name
    David 1
    James 2
    3 James
    3 Mike


    Now, I want to just the number of each name with the result, but don't know how I can do this with a sql?

    Thanks in advance.

    Who help me?

    SELECT b.Name, count(distinct a.ID)
    FROM TableA a, TableB b
    Where a.Sr = b.SrNew
    Group By b.Name
    

    Nicolas.

  • getting bad results with a query

    I have a column with the VARCHAR2 data type name (2) into a table and another table with a column named OFFICER_ZONE with the VARCHAR2 data type (1). What I'm trying to do is to compare these data and then insert it in the second table. But before you insert the data, if the AREA is equal to a number in double digits with a zero in front of her, then I need to CUT 0. If the BOX has a number greater than 9, then I have just these values to NULL. With the query below, I get the upper to 9 zones to be null, which is correct, but I also have those who are the two numbers with a zero not significant, which is not correct.

    For example:
    Area
    1
    2
    5
    07
    15
    19
    14
    6
    02
    d
    c
    e
    b

    Results:
    Bad area: 07
    Bad box: 15
    Bad area: 19
    Bad box: 14
    Bad area: 02

          --ZONE BAD DATA
          IF CR.ZONE NOT IN ('a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u',
              'v','w','x','y','z','A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z',
              '0','1','2','3','4','5','6','7','8','9')
          THEN
              V_OFFICER_ZONE := NULL; 
              DBMS_OUTPUT.PUT_LINE('ZONE NOT VALID:'||CR.LOCCASENUM||CR.ZONE);
              insert into pursuits.pursuit_exception(case_number,table_name,error_message)
              values(cr.loccasenum,'PURSUIT','Bad Zone: '||v_officer_zone||','||cr.zone);
          ELSE
              V_OFFICER_ZONE := TRIM(LEADING 0 FROM CR.ZONE);
          END IF;
    with t as (
               select '1' zone from dual union all
               select '2' from dual union all
               select '5' from dual union all
               select '07' from dual union all
               select '15' from dual union all
               select '19' from dual union all
               select '14' from dual union all
               select '6' from dual union all
               select '02' from dual union all
               select '0' from dual union all
               select '00' from dual union all
               select 'd' from dual union all
               select 'c' from dual union all
               select 'e' from dual union all
               select 'b' from dual
              )
    select  zone,
            case
              when length(zone) = 1
                then zone
              when zone between '00' and '09'
                then substr(zone,2)
              else null
            end officer_zone
      from  t
    /
    
    ZONE OFFICER_ZONE
    ---- ------------
    1    1
    2    2
    5    5
    07   7
    15
    19
    14
    6    6
    02   2
    0    0
    00   0
    
    ZONE OFFICER_ZONE
    ---- ------------
    d    d
    c    c
    e    e
    b    b
    
    15 rows selected.
    
    SQL> 
    

    SY.

Maybe you are looking for