Group by to ignore the values null

Hi all
Oracle version 10 g 2
Consider the scenario

Table: point
Columns: Itm_id, Itm_type, appl_y_n (VALUES VALID 'Y', ' n, NULL)

I HAVE FOLLOWING ITEM TYPES.

TYP1
TYP2
TYP3

In this appl_y_n is applicable only to the item type typ1 and it can contain y, n, or null.
Types of remaining elements of this field may contain any value, including null, but I want to ignore these values.
ITM_ID     ITM_TYPE     APPL_Y_N
1     TYP1     NULL
2     TYP1     Y
3     TYP1     N
4     TYP2     NULL
5     TYP2      NULL
6     TYP3     NULL
7     TYP3     NULL
now I need a group of clause which must ignore values null to appl_y_n only for TYP1

on top of the sample output must be
ITM_TYPE     APPL_Y_N     CNT
TYP1     YES     1
TYP1     NO     1
TYP2     NULL     2
TYP3     NULL     2
Query, that I use for this:

Select ITEM_TYPE, COUNT (ITM_ID), decode (itm_type, 'TYP1', DECODE(APPL_Y_N,'Y','Yes','N','No')) APPL_Y_N
of the order of the day
Item_type group, decode (itm_type, 'TYP1', DECODE(APPL_Y_N,'Y','Yes','N','No'))

But he's considering typ1 as null values.

Please give me a solution that ignores null values

Thanks in advance
NM

Hello

Check the below. It will be useful.

SQL >
SQL > WITH t AS)
2 SELECT 2 ITM_ID, 'TYP1' ITM_TYPE, 'Y' APPL_Y_N FROM dual UNION ALL
3. SELECT 3 ITM_ID, 'TYP1' ITM_TYPE, "n" APPL_Y_N FROM dual UNION ALL
4. SELECT 1 ITM_ID, 'TYP1' ITM_TYPE, APPL_Y_N NULL FROM dual UNION ALL
5. SELECT 4 ITM_ID, "TYP2' ITM_TYPE, APPL_Y_N NULL FROM dual UNION ALL
6. SELECT 5 ITM_ID, "TYP2' ITM_TYPE, APPL_Y_N NULL FROM dual UNION ALL
7. SELECT 6 ITM_ID, "TYP3' ITM_TYPE, APPL_Y_N NULL FROM dual UNION ALL
8. SELECT 7 ITM_ID, "TYP3' ITM_TYPE, APPL_Y_N double NULL)
9 SELECT itm_type,
10 DECODE (itm_type, 'TYP1', DECODE (appl_y_n, 'Y', 'Yes', "n","no")) appl_y_n,.
11 COUNT (itm_id)
12 FROM t
13 WHERE NOT (itm_type = 'TYP1' AND APPL_Y_N IS NULL)
14 group of itm_type,
15 decode (itm_type, 'TYP1', DECODE (APPL_Y_N, 'Y', 'Yes', "n","no"))
16 ORDER BY itm_type
17.

ITM_TYPE APPL_Y_N COUNT (ITM_ID)
-------- -------- -------------
TYP1 NO. 1
TYP1 Yes 1
TYP2 2
TYP3 2

SQL >

Rgds
Ameya

Tags: Database

Similar Questions

  • Siri in him sending text with the value 'NULL '.

    When I say, "Siri, text my wife, 'X', ' Siri responds correctly,"here is your message to Jill: 'X'. "" "  "Ready to send it?"  I say 'Yes' and sends the message.  As soon as I get a text from my carrier saying the recipient of the message was invalid.  100% of the time, I see that Siri has sent a text with the value NULL.

    I tried to restart my phone.  I tried to remove and re-add my contacts.  Anyone else having this problem?  Someone knows how to solve?

    If it's by the carrier, you should contact them and see what they receive in return for their side. Ive had Siri send messages for me and I have never seen this one IOS.

  • using the value null with a function

    Guys, newbie here

    What is the value NULL in function header? Does this mean that I can pass a value zero?

    FUNCTION tot_sales

    (company_id_in IN company.company_id%TYPE,

    status_in IN order.status_code%TYPE: = NULL)

    RETURN NUMBER

    Hello

    dorianpc wrote:

    Guys, newbie here

    What is the value NULL in function header? Does this mean that I can pass a value zero?

    FUNCTION tot_sales

    (company_id_in IN company.company_id%TYPE,

    status_in IN order.status_code%TYPE: = NULL)

    RETURN NUMBER

    You can always pass NULL for any argument.

    What does this code mean, is that the argument is optional (what, you don't have to spend), and if you do not pass it, status_in will be NULL inside the function.

    So call for your function with 1 argument, like this:

    t: = to_sales (c);

    is equivalent to calling with 2 arguments, like this

    t: = to_sales (c, NULL);

    where the 2nd argument is null.

  • Calculated field with the currency formatting, and hiding the values null

    I am designing a PDF form for quote and I have a field defined to multiply the amount of an article and the unit price to the total price.  There are 5 lines on each quote, and if users are citing only 1 or 2 items I want the values null in fields unused price extended to be hidden.

    I did it with the following script

    If (event.value == 0) event.value = ";

    But when I enter the quantity and total price of price is displayed as a regular number (100) instead of currency ($100).

    I can format to currency with

    Event.Value = util.printf ("$%.2f", event.value);

    I don't know there's a way to combine to give rise to such a situation then, so if the field is 0, make null and if not then format as currency but I don't know how to do it.

    Any help would be appreciated.

    Andrew

    Newer versions of Acrobat hide zero for fields values using the number format and with a currency symbol. »

    But since you can't control the updating of user systems, you must use a small function documented for formatting numeric fields on the fly.

    With the extended price field set to 'None' format, you can add the following script to the Validation script "Custom" or add it to a custom JavaScript calculation. The "Custom Validation will work with any method of calculation. Note that the form must be cleaned or recalculated to see the result of the validation script change.

    if(Event.Value == 0) {}
    Event.Value = ""; set the field value to null to a value of zero
    AFNumber_Format (2, 0, 0, 0, "", true); number with no currency symbol format
    } else {}
    AFNumber_Format (2, 0, 0, 0, "$", true); for the format of the values non-null for number with the currency symbol
    }

    The positional parameters are the number of decimal places, the Style separator, negative value Style, Style of (unused) currency, currency symbol, the currency symbol Pre-hanging chain.

  • Compare the value Null

    Hello

    Is it possible to compare a null to null...

    Example of
    ---------------------------
    Indicator number;

    If null = null then
    flag = 1;
    on the other
    flag = 0;
    end if;
    ---------------------------

    Thank you.

    Hello

    Use "is null".

    For example:

    declare
    VARCHAR2 (10) variable;
    Start
    If the variable is null then
    dbms_output.put_line ('variable is null');
    on the other
    dbms_output.put_line ("'variable is non-zero");
    end if;
    end;

    By comparing the value null = null will not work.

  • How do I ignore the blanks/Null in mapping FDMEE

    Hello team, I have a file source format below.

    In it so I need to ignore the lines which is having the entity as null how do I design the data mapping in FDMEE. Please notify. I have need the lines with null to go on the target system

    Account entitty year project pc SupportSystem Site
    645WE2014growthPc1100BSSSite1
    6552014growthpc1230Site1
    656PEUT2014growthPc1234BSSTraining3

    Thank you

    Mouline

    Hello

    Do not export data, you must set the target value to IGNORE

    To capture entities null (empty), you have the mapping, but it works only with whitespaces channels not empty...

    However, you have several ways to achieve what you want according to your needs. For example:

    -Option 1: create a script to import then empty entities are imported as white space and then use the mapping of (see details in the Administrator's guide) to map to IGNORE

    -Option 2: create mappings for the valid entities, and then create a mapping rule that maps to IGNORE (this mapping rule is performed last)

    -Option 3: skip lines with an empty entity in the import format. Then these lines will not be imported in FDM so you don't need to map...

    -The other options...

    I hope that clarifies.

    See you soon

  • Getting the value null inserted in the back end when the field is turned off

    Hi gurus,

    I have a TOTAL field that is the sum of the other two fields in a form. I have disabled because do not have the user enter the value. The TOTAL field is the poster of the sum of the values in the front end, but in the back-end, the value is null. Please help me solve this problem. Thanks in advance.

    Have you tried to make the point read-only? Set the read-only item and try. You can do the unalterable element by two methods,

    (1) amend section-> go to read only tab-> read-only Condition Type: always

    (2) create a dynamic Action-> event: loading the Page-> Action: run the JavaScript Code-> Code:

    $('#P1_TEST').attr ('readOnly', true);

    $('#P1_TEST').css ('background-color', '#CDCDCD');

    Tom wrote:

    set the item read-only instead (not editable by the user but will present)

    Set the element value using the da no need to activate the item before submitting because the element is not disabled. Make the point read-only so that it will submit the value to the session and point cannot be changed always.

    Thank you

    Lacombe

  • What is the empty string, the value null in the column, or...?

    I use Oracle 11.2, a table tb_class as follows:

    TB_CLASS (number (3) id, varchar2 (32) nm, seqNum number (3));

    1, 212
    2, "under", 12
    3, 'qq', 12

    Select * from TB_CLASS where id = 1 and n = null;... .no selected line
    Select nvl (nm) in the TB_CLASS where id = 1; ... 1 selected line

    Any know what's in the column of row id = 1 nm? I thought that it is an empty string, but why it returns no rows in the first query?

    Thank you!

    (1) in Oracle there is no difference between NULL and an empty string.

    (2) NULL is never equal to what whatsoever (including another NULL). NULL is never spotty what whatsoever (including another NULL). You must use the IS NULL and IS NOT NULL operators to search for NULL values

    SELECT *
      FROM tb_class
     WHERE nm IS NULL
    

    or

    SELECT *
      FROM tb_class
     WHERE nm IS NOT NULL
    

    Of course, it is also possible that you declare that the NM column contains one or more spaces or it contains one or more non-printable characters and not a NULL value. That's why we asked you what dump (nm) returns

    Justin

  • Creation of the logic group - no limitation for the value of criteria field?

    I am trying to create simple logical groups in FDM (11.1.1.3 and 11.1.2.1 version). However, an error message is displayed in the information bar.

    : Error adding the new record.
    Detail: data access error.

    I clicked on the button "Add" and created a logical group that contains * 1 520 * accounts not sequential sources in the field of value of criteria (with operator).
    I separated these accounts from source with a comma and no space between them. (Note: operator = x, value/Exp = 1, Seq = 0) I've updated the grid. Then the error message was displayed and the logical group create failed.

    And then, I created a new group of logic that contains only * 100 * accounts not sequential sources in the field of value of criteria (with operator).
    I also separated a comma, no spaces and the same setting. I've updated the grid. And the logical group has been successfully added.

    The account of each source contains 10 characters (alphabet and number).

    I want to ask:
    1. is there a limitation by specifying accounts sources (i.e.. more than number of accounts for each group of logic source) in the criteria value field when creating simple logical group?

    2. I'm adding these logical groups by clicking on the button 'Add' one by one, is it faster way to do (i.e. transfer an excel or csv source file specified accounts)?

    Thank you very much!

    You perform the update the named range in the Excel file as the previous poster said? When you import an Excel file using the import XLS function, only the name family (s) starting with 'ups' are actually loaded in the system. Note that at least in versions 9.3 and 11.1.1.3 there was also some hidden lines had to be such that specify the header.

    JOINT TASK FORCE

  • What SYS tables (not seen) contains the value NULL spec /not/ column definition?

    What SYS (or tables) store the value of a spec /not/ NULL columns? (It doesn't seem to be COL$)

    NOTE: This is NOT a trick question - although it seems to be.

    Test configuration:
    BANNER
    Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - Production
    PL/SQL Release 11.2.0.1.0 - Production
    CORE     11.2.0.1.0     Production
    TNS for Linux: Version 11.2.0.1.0 - Production
    NLSRTL Version 11.2.0.1.0 - Production
    Test configuration:
    1. a table is created by SCOTT in the SCOTT schema with a NULLABLE column.

    2. a primary key constraint is added using only the NULLABLE column

    3. Requests for information on USER_TAB_COLS, ALL_TAB_COLS, DBA_TAB_COLS and SYS. COL$ see NOT NULL for the column NULLABLE
    as necessary for a primary key constraint. Views derive their data from the column of $ NULL the sys. Table of $ COL
    using
    'DECODE (SIGN (c.null$), -1, 'D', 0, 'Y', 'N'),
    and the table of $ COL shows a numerical value of '0' before you add the primary key and a value of "1" later.

    4. a query on the DDL metadata table shows the specification for column NULLABLE of origin involved.

    Question - where this original specification NULLABLE is stored?

    This question is based on a question asked by another user in this thread
    Columns becoming nullable after a fall of primary key?

    I created the following specially for that matter test case
    -- scott ensures table does not exist
    DROP TABLE tbl_test CASCADE CONSTRAINTS;
    
    -- scott creates a table
    CREATE TABLE tbl_test ( col_1 NUMBER,
    col_2 NUMBER NOT NULL);
    
    -- scott queries to check the the column nullable status
    SELECT table_name, column_name, nullable 
    FROM user_tab_cols
    WHERE table_name = 'TBL_TEST';
    
    -- TABLE_NAME | COLUMN_NAME | NULLABLE
    -- TBL_TEST   | COL_1       | Y 
    -- TBL_TEST   | COL_2       | N 
    
    -- Scott addes a primary key constraint using only the nullable column
    ALTER TABLE tbl_test ADD CONSTRAINT tbl_test_pk PRIMARY KEY(col_1);
    
    -- scott queries to check the the column nullable status
    SELECT table_name, column_name, nullable 
    FROM user_tab_cols
    WHERE table_name = 'TBL_TEST';
    
    TABLE_NAME,COLUMN_NAME,NULLABLE
    TBL_TEST,COL_1,N
    TBL_TEST,COL_2,N
    
    -- scott queries to get the table DDL
    select dbms_metadata.get_ddl('TABLE', 'TBL_TEST', 'SCOTT') FROM DUAL;
    
    DBMS_METADATA.GET_DDL('TABLE','TBL_TEST','SCOTT')
    
      CREATE TABLE "SCOTT"."TBL_TEST" 
       (     "COL_1" NUMBER,                   <------ where is this NULLABLE spec stored? 
         "COL_2" NUMBER NOT NULL ENABLE, 
          CONSTRAINT "TBL_TEST_PK" PRIMARY KEY ("COL_1")
      USING INDEX PCTFREE 10 INITRANS 2 MAXTRANS 255 COMPUTE STATISTICS NOCOMPRESS LOGGING
      TABLESPACE "USERS"  ENABLE
       ) SEGMENT CREATION DEFERRED 
      PCTFREE 10 PCTUSED 40 INITRANS 1 MAXTRANS 255 NOCOMPRESS LOGGING
      TABLESPACE "USERS" 
    The DOF shows that Oracle keeps the original spec NULLABLE for the column and uses it to generate the DDL orginal, even if there is a primary key on the table and the system views (and COL$) show the column non NULLABLE.

    So where is the original information NULLABLE actually stored?

    rp0428 wrote:
    What SYS (or tables) store the value of a spec /not/ NULL columns? (It doesn't seem to be COL$)

    I think that it becomes a bit messy depending on order of activity:

    You can see Col. .null$ is set to a non-zero when the desrcibe command displays the column as not null, but it can happen for two reasons:
    (a) user sets the column as not null - in which case you get a line in cdef$ with type # = 7
    (b) the user adds a primary key to table - in which case you get a line in cdef$ with type # = 2

    If you declare null AND add a primary key, you get two lines - that's why it is possible for Oracle to determine if he should remove the flag not null when you remove the primary key and also allows dbms_metadata show the create statement of table without a NOT NULL even when describe it the watch with a NOT NULL - dbms_metadata can respond to the presence of the type # = 2 and absence of the type # = 7.

    Concerning
    Jonathan Lewis

    By the way: by a strange coincidence, it seems to me answering the previous post, three days before it was asked: http://jonathanlewis.wordpress.com/2012/04/19/drop-constraint/#comment-46140 (on the doubts, this isn't - it answers a different question on the removal of constraints).

    Published by: Jonathan Lewis April 23, 2012 11:07

  • The values NULL in Rosetta Net received recognition for SOA 11.1.1.5

    Hello

    My business partners are reporting that they have consumer issues of the receipt we send them

    That's because we send it null values or wrong

    Can you tell me how can I fix?

    Here is an example

    <? XML version = "1.0" encoding = "UTF-8"? >

    <! DOCTYPE ServiceHeader SYSTEM "ServiceHeader_MS_V02_00.dtd" >

    < ServiceHeader >
    < ProcessControl >
    < ActivityControl >
    < BusinessActivityIdentifier > notify of advance shipment < / BusinessActivityIdentifier >
    < Messagecontroler >
    < fromRole >
    Receiver of < GlobalPartnerRoleClassificationCode > < / GlobalPartnerRoleClassificationCode >
    < / fromRole >
    < fromService >
    < GlobalBusinessServiceCode >sending Service< / GlobalBusinessServiceCode >
    < / fromService >
    < inReplyTo >
    < ActionControl >
    < ActionIdentity >
    < GlobalBusinessActionCode > Advance Shipping Notification Action < / GlobalBusinessActionCode >
    < messageStandard >
    < FreeFormText > null < / FreeFormText >
    < / messageStandard >
    < standardVersion >
    value null < IdentificateurVersion > < / IdentificateurVersion >
    < / standardVersion >
    < / ActionIdentity >
    < messageTrackingID >
    < InstanceIdentifier > 3683 < / InstanceIdentifier >
    < / messageTrackingID >
    < / ActionControl >
    < / inReplyTo >
    <>Manifesto
    < numberOfAttachments >
    < CountableAmount > 0 < / CountableAmount >
    < / numberOfAttachments >
    < ServiceContentControl >
    < SignalIdentity >
    Acknowledgement of < GlobalBusinessSignalCode > < / GlobalBusinessSignalCode >
    < IdentificateurVersion > V02.00 < / IdentificateurVersion >
    < / SignalIdentity >
    < / ServiceContentControl >
    < / manifesto >
    < toRole >
    sender < GlobalPartnerRoleClassificationCode > < / GlobalPartnerRoleClassificationCode >
    < / toRole >
    < toService >
    < GlobalBusinessServiceCode >null< / GlobalBusinessServiceCode >
    < / toService >
    < / Messagecontroler >
    < / ActivityControl >
    Production of < GlobalUsageCode field > < / GlobalUsageCode field >
    < pipCode >
    3 b 2 < GlobalProcessIndicatorCode > < / GlobalProcessIndicatorCode >
    < / pipCode >
    < pipInstanceId >
    < InstanceIdentifier > gwf://10632/Notify of dispatch of advance < / InstanceIdentifier >
    < / pipInstanceId >
    < pipVersion >
    < IdentificateurVersion > V01.00 < / IdentificateurVersion >
    < / pipVersion >
    < KnownInitiatingPartner >
    < PartnerIdentification >
    < domain >
    DUNS < FreeFormText > < / FreeFormText >
    < / domain >
    < GlobalBusinessIdentifier > 055991053 < / GlobalBusinessIdentifier >
    < / PartnerIdentification >
    < / KnownInitiatingPartner >
    < / ProcessControl >
    < / ServiceHeader >


    Thank you for your help

    Please log a service request with support. I think you hit a known issue.

    Kind regards
    Anuj

  • Not ignore the values of numbers

    Hello
    I have a column that contains a number stored as text, and I want to do some calculations on this column. So, if I use TO_NUMBER function, but the problem that some values are not really numbers like '4 a' I want to bypass or ignore the calculations on these values.
    Can I do this in SQL without PL/SQL?

    Saad,

    Use REGEXP_SUBSTR(col,'[0-9]+') to extract only the numeric part

  • How to determine if a control on a form has the value NULL

    I have a form with some fields that are not necessary. Once the user completes the form and click on send, I write back form fields values to a .db file. Problem, I'm running into is that, if a form textinput field is left empty, my insert statement fails because he says "hand Thread (Suspended: TypeError: Error #1009: cannot access a property or method of an object. null reference)" for the value of the blank form field (in the example below, 'phone' is not necessary).

    var sql:String =
    "INSERT INTO investigation." + "
    "(firstName,» +)"
    'lastName ', +.
    "email" +.
    "phone" +.
    'bio ' +.
    ") " +
    'VALUES ' +.
    "('" + firstnameValid.text+",)" "" "
    ' + lastnameValid.text +' "," '.
    ' + emailValid.text +' "," '.
    ' + phone.text +' "," '.
    + bio.text + "')";

    I tried:

    var phone_input:String;
    If (phone.data == "")
    {phone_input = ' ' ;}}
    on the other
    {phone_input = phone.text ;}

    But get the same error on the if (phone.data == "") line.

    Any suggestions? Thank you!


    I'm a little confused, then, I think. The error seems to imply that there is no 'phone' and so try to call the 'data' or 'text' on it throws the error you see. The only other suggestion I could make (without seeing the code) would be to try something more vague, such as:

    [code]
    var phone_input:String;
    If (! phone) {}
    phone_input = "";
    } else {}
    phone_input = phone.text;
    }
    [/ code]

    Or, if you prefer a little shorter code, something like the following should work:

    [code]
    var phone_input:String = (! phone)? "": phone.text;
    [/ code]

    Or, if you're the kind of person who likes using the try/catch blocks, why not do something like this for a spin:

    [code]
    var phone_input:String;
    try {}
    phone_input = phone.text;
    } catch (err: TypeError) {}
    phone_input = "";
    }
    [/ code]

    Hope that helps,

    Peter

  • LOV selection list with submit the value Null

    I have a select list with submit in which another fileld fills based on the selection. I have the TEXT Null in the LOV "Select Vendor" value but I do not know how to set the Null VALUE, while I get this error:

    ORA-01722: invalid number
    Calculation of default value of the element of error ERR-1019: page = 2 name = P2_VEND
    Ok

    I tried the following to the default value of the select list with submit without result:
    Replace (: P2_VEND, '%' | 'null %', null)

    Thanks in advance.

    Hello

    You can set the NULL value - 1 (or any other provider code which may not exist).

    Greetings,
    Roel

    http://roelhartman.blogspot.com/

  • Ignore the value inserted manually in the field of the lov

    Hi all

    I have a field called exchange_rate, the user can choose the value of lov (input text with lov) or can manually insert it in the same field.

    for example the lov contains values 0.20 - 0.30 - 0.40 and the user must insert the 0.35 value that does not exist in lov.

    How to do this?

    You can try to remove the f: validator tag.

    or (if the previous suggestion does not help)

    You can add the new attribute to your VO and set rather LOV him on the original attribute (when you add lov in this field, you must also update the original attribute)

    Then use af:inputText for your attribute (so it will not be validated for lov) original and put new attribute as af:inputListOfValues next to him (for example, you can surround them with af:panelGroupLayout with layout = "horizontal").

    Hide a part of your LOV entry by placing "display: none;" in "contentStyle" property then you will see only lov icon and combination (inputText, inputListOfValues) will look like to users as classic lov.

    To refresh the inputText when the user chooses something else of lov, you need to define autosubmit = true on your component lov and add partial trigger in af:inputText that points to your lov.

    Dario

Maybe you are looking for

  • Re: Tecra M9 - 15I - HDD that upgrade?

    I think of upgrading my laptop HARD drive. I seek through my options and don't know whether to go for a HARD disk with a rpm of 5400 or 7200. Read information from the manufactureres, a 7200 RPM hard drives are usually better. But no one knows how th

  • Should Qosmio G40 - 10F - we support a 12mm hard drive?

    I searched the internet for this, and I found a few sites say that it supports a hard drive of 12mm in its Bay, and others have said not that at all. "I just want confirmation that a 12mm of the 2.5 HDD", we can insert in the laptop, I want to upgrad

  • Pavilion p6130y power supply upgrade

    Remember to upgrade the power on desktop p6130y Pavilion 300W at best it can support but couldn't find the answer.  Could someone tell me the stronger power supply that will support this device?  Thank you.

  • Upgrade memory 520-1050 TS

    It would have been great if the 520-1050 TS came with its maximum in memory of 8 MB instead of 6 MB, but no problem, it can be upgraded. My question, it seems 2 types of memory upgrades can be used and wanted to find who I use because I've always lov

  • ActiveX control installation steps

    Hello Can someone help me in installation of control ActiveX in Vista, that this s/w does not allow to install. This is a very urgent request on the forum. Aprriciate if answered quickly!