Suppression of zeros of column

How can I remove the zeros of a column?

The data looks like to * 00-04-071 *.

The output should display 4071
SQL> select ltrim(replace('00-04-071','-'),'0') from dual
  2  /

LTRI
----
4071

SQL> 

SY.

Tags: Database

Similar Questions

  • Suppression of zeros of a column

    Hello
    I want to remove the zeros of a column of varchar type that allows to store alpha numeric characters.

    Here's the scenario:
    0-> 0
    00-> 0
    000-> 0

    If I use ltrim(column,'0') it returns null


    Thank you
    Manoi.

    Published by: user518071 on February 22, 2010 12:00

    Or

    SQL> with t as (
     select '0' str from dual union all
     select '00x42' from dual union all
     select '000AB' from dual union all
     select null from dual
    )
    --
    --
    select str, regexp_replace(str, '^0+', '0') str2 from t
    /
    STR   STR2
    ----- ------------------------------
    0     0
    00x42 0x42
    000AB 0AB                           
    
    4 rows selected.
    
  • Suppression of zeros of a string value

    Hi all

    I have a requirement like, I need delete zeros of a string value.

    like, 00Raj00Shekar is > Raj00shekar.

    How can I do this?

    If it is only with custom functions, where can add fuction to Jdeveloper and SOA Middle ware?

    Thanks in advance,

    REDA

    Hi reda,.

    You can use following function to get the result desired by xsl.

    HTH,

    Kind regards

    Vikas marzouk

  • How to get no value zero to a data set

    Here is my SQL statements:

    WITH T1
         AS (SELECT 'i1' ITEM,
                    'L1' LOC,
                    SYSDATE - 7 DAT,
                    0 QTY
               FROM DUAL
             UNION ALL
             SELECT 'i1' ITEM,
                    'L1' LOC,
                    SYSDATE DAT,
                    100 QTY
               FROM DUAL
             UNION ALL
             SELECT 'i1' ITEM,
                    'L1' LOC,
                    SYSDATE + 7 DAT,
                    0 QTY
               FROM DUAL
             UNION ALL
             SELECT 'i1' ITEM,
                    'L1' LOC,
                    SYSDATE + 14 DAT,
                    20 QTY
               FROM DUAL
             UNION ALL
             SELECT 'i1' ITEM,
                    'L1' LOC,
                    SYSDATE + 21 DAT,
                    10 QTY
               FROM DUAL
             UNION ALL
             SELECT 'i1' ITEM,
                    'L1' LOC,
                    SYSDATE + 28 DAT,
                    0 QTY
               FROM DUAL
             UNION ALL
             SELECT 'i2' ITEM,
                    'L2' LOC,
                    SYSDATE DAT,
                    0 QTY
               FROM DUAL
             UNION ALL
             SELECT 'i2' ITEM,
                    'L2' LOC,
                    SYSDATE + 28 DAT,
                    0 QTY
               FROM DUAL
             UNION ALL
             SELECT 'i3' ITEM,
                    'L3' LOC,
                    SYSDATE DAT,
                    10 QTY
               FROM DUAL
             UNION ALL
             SELECT 'i3' ITEM,
                    'L3' LOC,
                    SYSDATE + 28 DAT,
                    0 QTY
               FROM DUAL
             UNION ALL
             SELECT 'i3' ITEM,
                    'L3' LOC,
                    SYSDATE DAT,
                    230 QTY
               FROM DUAL)
    SELECT *
      FROM t1;
    

    Current output

    Capture.PNG

    Expected results:

    Capture1.PNG

    Logic:

    For a point order and the particular location by date (ascending order) first non - zero qty column should be filled with zero qty column

    for example,.

    For i1 and Loc l1 point, we have 6 entries and Jan 07, Jan 21st and Feb 11 we have zero quantities and Jan 14th, 28 Jan and Feb 04 have non - zero quantities, when all of this is stopped by date, amount of 14 Jan must stem from Jan 07, Jan 28 should be established on 21st January and Feb 11 is to have zero quantity but there is no record found after that if she should remain such what.

    Similar logic for all other combinations

    What I tried: I tried to realize using first_value analytic function that is not just my output

    Thank you for your help in advance

    It is a bit of a hack, but how about...

    -case when qty = 0 then nvl (lead (decode (qty, 0, to_number (null), qty) ignore nulls) over (partition by element, loc in order of dat), 0) other end qty

  • How to make a NULL handle with different columns

    Hi gurus,

    I need the Oracle in the reports:

    For example:-J' have a Temp table with three columns A, B and C

    My requirement is IF the columns A, B and C are null in the report he should return C 0, B as none and none.
    If all values are there in columns A, B or C, then report output should return these values.

    All your contributions are much appreciated.

    Thank you

    When column c is null, column should return zero and column b return zero and column c 0.
    If column C is not null, then it must return the values that are present in their respective columns.

    select nvl2 (c, a, 'None') a, nvl2 (c, b, 'None') b, nvl (c, 0) c from temp
    
  • How to eliminate zeros after the decimal point

    Hello

    I have the columns in the table of Planner has BEGIN_DAY BEGIN_MONTH BEGIN_YEAR and the values are coming as 12.00, 11.00, 2009.00.

    In the database there are no zeros after the decimal point, but when the tables are imported into OBIEE see zeros in columns above. Is it possible to remove the zeros after the decimal place to the RPD.

    Rgds,
    Amit

    Set the data type in the physical layer int.

  • Add a new column in a CREATE - AS SELECT statement

    I create a table using a select in an existing table. I would also like to add a new column (with nulls for all records). Is this possible? What is the syntax for this column?

    Thank you
    Kevin

    user10856100 wrote:
    I create a table using a select in an existing table. I would also like to add a new column (with nulls for all records). Is this possible? What is the syntax for this column?

    Thank you
    Kevin

    Kevin,
    In any case, create table will not accept one byte NULL for the column declaration.

    SQL> create table e(empno,ename, sal, new_co) as select  empno,ename, sal, to_number(null) from emp;
    create table e(empno,ename, sal, new_co) as select  empno,ename, sal, to_number(null) from emp
                                                                          *
    ERROR at line 1:
    ORA-01723: zero-length columns are not allowed
    
    SQL> create table e(empno,ename, sal, new_co) as select  empno,ename, sal, to_number('12') from emp;
    
    Table created.
    
    SQL> desc e
     Name                                      Null?    Type
     ----------------------------------------- -------- ----------------------------
     EMPNO                                              NUMBER(4)
     ENAME                                              VARCHAR2(10)
     SAL                                                NUMBER(7,2)
     NEW_CO                                             NUMBER
    
    SQL> select * from e;
    
         EMPNO ENAME             SAL     NEW_CO
    ---------- ---------- ---------- ----------
          7369 SMITH               0         12
          7499 ALLEN               0         12
          7521 WARD                0         12
          7566 JONES               0         12
          7654 MARTIN              0         12
          7698 BLAKE               0         12
          7782 CLARK               0         12
          7788 SCOTT               0         12
          7839 KING                0         12
          7844 TURNER              0         12
          7876 ADAMS               0         12
    
         EMPNO ENAME             SAL     NEW_CO
    ---------- ---------- ---------- ----------
          7900 JAMES               0         12
          7902 FORD                0         12
          7934 MILLER              0         12
          7369 SMITH               0         12
          7499 ALLEN               0         12
    
    16 rows selected.
    

    HTH
    Aman...

  • Simple MathScript works very slowly.

    Howdy all,

    I have something that seems to be a very simple script:

    If delt'alarme == 0
    NewArray = datain;
    on the other
    [lines columns] = size (datain);
    timediff datain = (2,1) - datain (1,1);
    totrow = delt / timediff;
    numrun = lines - totrow;
    NewArray = zeros (numrun, columns);
    II = 1:numrun
    NewArray (ii, = [datain(ii+totrow,1) mean (datain (ii:ii + totrow, 2:columns))];)
    end
    end
    Output 1 = 1;

    So the code is taking a time to average turnover of some data. Put the same data in MATLAB takes much less than a second to run, according to delt (the number of seconds of the average), but can be as low as 5-100ths of a second. In Excel, it can calculate it in about 0.5 seconds, but in LabView, it will take at least 10 seconds and up to a minute for a long (10 seconds) moving average.

    Why is it so slow in LabView?

    See you soon,.

    James

    OK, here's a quick project to a pure g version. It takes about 60ms on my computer for the calculation of the average of the existing files.

    (See if it is a faster. I'm sure that there is a little slack left and it could be sped up a little with some fine adjustment).

    Your code has a few problems, for example it uses 100% CPU when it does nothing (place of indicator on the two terminals of the iteration to see why). I don't like the stacked while loops. I used to place a structure of the event. A lot of management should be added, for example errors is so fine-2 but 1 file is missing, for example. You have a certain oercions of output on your mathscript node, for example distort the dimensionality of the tables.

    Anyway, the researcher should help you get started... Most likely, there are a few bugs...

  • SQLite problems HELP!

    Hello

    I use the database local sqlite for my application that worked very well. When the main screen is launched, the application must search in the database and create a vector of all entries in the specified table (there are about 1900 entries). A few columns added to the database and now only the first 8 entries are being extracted from the database. I have the code line by line with the debugger and does not find the problem. Below, I've posted the code in my databasehelper file:

        Vector getItems()
        {
            Vector business = new Vector();
    
            try
            {
                // Read in all records from the Businesss table
                Statement statement = _db.createStatement("SELECT * FROM BUSINESSLISTING");
                statement.prepare();
                Cursor cursor = statement.getCursor();
    
                // Iterate through the the result set.  For each row, add a
                // new Business object to the vector.
    
                while(cursor.next())
                {
                    Row row = cursor.getRow();
    
                    int BUSINESS_ID = row.getInteger(0);
                    String BUSINESS_NAME = row.getString(1);
                    String BUSINESS_CATEGORY = row.getString(2);
                    int BUSINESS_PHONENUMBER = row.getInteger(3);
                    String BUSINESS_WEBSITE = row.getString(4);
                    String BUSINESS_STREET = row.getString(5);
                    String BUSINESS_CITY = row.getString(6);
                    String BUSINESS_STATE = row.getString(7);
                    int BUSINESS_ZIPCODE = row.getInteger(8);
                    int BUSINESS_COUNTY = row.getInteger(9);
                    String BUSINESS_BIO = row.getString(10);
                    String BUSINESS_DOWNTOWN = row.getString(11);
                    String BUSINESS_CHAMBER = row.getString(12);
                    String BUSINESS_FEATURED = row.getString(13);
                    String BUSINESS_COUPONID = row.getString(14);
                    String BUSINESS_HOURS = row.getString(15);
                    String BUSINESS_IMAGEID = row.getString(16);
                    float BUSINESS_LAT = row.getFloat(17);
                    float BUSINESS_LONG = row.getFloat(18);
    
                    Business item = new Business(BUSINESS_ID, BUSINESS_NAME, BUSINESS_CATEGORY,
                            BUSINESS_PHONENUMBER, BUSINESS_WEBSITE, BUSINESS_STREET, BUSINESS_CITY,
                            BUSINESS_STATE, BUSINESS_ZIPCODE, BUSINESS_COUNTY, BUSINESS_BIO, BUSINESS_DOWNTOWN,
                            BUSINESS_CHAMBER, BUSINESS_FEATURED, BUSINESS_COUPONID, BUSINESS_HOURS,
                            BUSINESS_IMAGEID, BUSINESS_LAT, BUSINESS_LONG);
    
                    business.addElement(item);   
    
                }
                statement.close();
                cursor.close();
            }
            catch(DatabaseException dbe)
            {
             //   SQLiteDemo.errorDialog(dbe.toString());
            }
            catch(DataTypeException dte)
            {
             //   SQLiteDemo.errorDialog(dte.toString());
            }  
    
            return business;
        }
    

    Again, the code was working before great... I have not changed anything. Someone at - it suggestions?

    It can come from a value zero / Nullable column arrived when you have added your new columns in a database that is already populated.

    It rises an exception?

    Have you tried to delete your database and rebuild?

    Have you checked the mental health of your database with a graphical tool to your computer?

  • IFTHEN help financial information

    Hello

    You will need to if so logical. I have the below:

    If the column A and column B is less than zero then (A - B) *-1 else (A - B).

    IFTHEN (([A] < 0 et [B] < 0), EVAL (([A]-[B]) *-1), EVAL ([A] - [B]))

    I need:


    If the column A and column B are below zero AND column B is less than column A then (A - B) *-1 else (A - B).

    How do I nest in this CASE 2?

    Hello

    I'm doing this from memory because I am sure that he used to work, but never described. Try (excludes the hooks you need around the names of columns because of the formatting):

    IfThen (C< 0="" and="" b="0" )="" ,="" -1,="" if="" (="" c="0," 0,="" if="" (="" b="">< 0,="" eval="" (="" (="" c="" b="" )="" *="" -1),="" eval="" (="" c="" b="" )="" )="" )="">

    If this does not work, try replacing the Ifby IfThen's.

    Let me know if it helps
    Stuart

  • create the table in SELECT (question)

    Hello

    In regards to create the table as subquery, I read that:

    The data type of column definitions and the NOT NULL constraint are passed to the new table. Note that only the explicit NOT NULL constraint is inherited. The PRIMARY KEY column will not function NOT NULL column null. Any other rule of constraint is not passed to the new table. However, you can add constraints in the column definition.

    Can someone explain to me how to do this? Or, how we need to specify the constraints (and also the default values for columns, because it is possible) for the columns in the column definition?

    In addition, I do not understand this: the PRIMARY KEY column will not function NOT NULL column zero.
    Can someone give me some small examples regarding these?
    For example, it generates an error:
    create table test1 (a, b, c default sysdate) 
    as 
    select 1, 'b' from dual
    Thank you!

    Edited by: Roger22 the 01.09.2011 11:37

    Hello

    When you set a primary key consists of a unique constraint and a constraint not null, but they are both implicit with the primary key. When you create the table because it will copy only the explicitly declared NOT NULL constraints so it isn't look upward than the implicit NOT NULL primary key.

    SQL> create table dt_pk
      2  (   id      number primary key,
      3      col1    number not null,
      4      col2    number
      5  )
      6  /
    
    Table created.
    
    SQL> desc dt_pk
     Name                                      Null?    Type
     ----------------------------------------- -------- ----------------------------
     ID                                        NOT NULL NUMBER
     COL1                                      NOT NULL NUMBER
     COL2                                               NUMBER
    
    SQL> create table dt_pk2 as select * from dt_pk;
    
    Table created.
    
    SQL> desc dt_pk2;
     Name                                      Null?    Type
     ----------------------------------------- -------- ----------------------------
     ID                                                 NUMBER
     COL1                                      NOT NULL NUMBER
     COL2                                               NUMBER
    
    SQL> select constraint_name,constraint_type from user_constraints where table_name='DT_PK'
      2  /
    
    CONSTRAINT_NAME                C
    ------------------------------ -
    SYS_C006935772                 C
    SYS_C006935773                 P
    
    SQL> select constraint_name,constraint_type from user_constraints where table_name='DT_PK2'
      2  /
    
    CONSTRAINT_NAME                C
    ------------------------------ -
    SYS_C006935774                 C
    

    However, a primary key can reuse existing constraints and indexes instead of declaring new. For example, we can explicitly declare a constraint not null on the column id and then create a primary key. This means that we will now inherit the constraint not null in the ETG, as it has been explicitly declared and is a constraint separate in there own right that has been 'borrowed' by the pk constraint.

    SQL> create table dt_pk3 (id number not null, col1 number not null, col2 number);
    
    Table created.
    
    SQL> alter table dt_pk3 add constraint dt_pk3_pk primary key (id);
    
    Table altered.
    
    SQL> select constraint_name,constraint_type from user_constraints where table_name='DT_PK3'
      2  /
    
    CONSTRAINT_NAME                C
    ------------------------------ -
    SYS_C006935775                 C
    SYS_C006935776                 C
    DT_PK3_PK                      P
    
    SQL> create table dt_pk4 as select * from dt_pk3;
    
    Table created.
    
    SQL> desc dt_pk3;
     Name                                      Null?    Type
     ----------------------------------------- -------- ----------------------------
     ID                                        NOT NULL NUMBER
     COL1                                      NOT NULL NUMBER
     COL2                                               NUMBER
    
    SQL> desc dt_pk4;
     Name                                      Null?    Type
     ----------------------------------------- -------- ----------------------------
     ID                                        NOT NULL NUMBER
     COL1                                      NOT NULL NUMBER
     COL2                                               NUMBER 
    

    Regarding the definition of the default values, you must always specify the column in the select, but doing so means follow you the semantics of a default in a standard INSERT statement, i.e. you specified the column, you must provide a value, in which case even if the value is null, the default value will not be used. However, the new inserted rows where the column with the default value is not specified will revert to the default.

    SQL> create table test1 (a, b, c default sysdate)
      2  as
      3  select 1, 'b' from dual
      4  /
    create table test1 (a, b, c default sysdate)
                        *
    ERROR at line 1:
    ORA-01730: invalid number of column names specified
    
    SQL> create table test1 (a, b, c default sysdate)
      2  as
      3  select 1, 'b', null c from dual
      4  /
    select 1, 'b', null c from dual
                   *
    ERROR at line 3:
    ORA-01723: zero-length columns are not allowed
    
    SQL> create table test1 (a, b, c default sysdate)
      2  as
      3  select 1, 'b', cast(null as date) c from dual
      4  /
    
    Table created.
    
    SQL> select * from test1;
    
             A B C
    ---------- - ---------
             1 b
    
    SQL> insert into test1(a,b) values(2,'b');
    
    1 row created.
    
    SQL> select * from test1;
    
             A B C
    ---------- - ---------
             1 b
             2 b 01-SEP-11
    

    To create a constraint, you must list all columns without the data types and constraints list online.

    SQL> create table dt_cons (id number, col1 number, col2 number, constraint chk2 check(col2 IS NULL or col2>10))
      2  as select * from dt_pk3
      3  /
    create table dt_cons (id number, col1 number, col2 number, constraint chk2 check(col2 IS NULL or col2>10))
                          *
    ERROR at line 1:
    ORA-01773: may not specify column datatypes in this CREATE TABLE
    
    SQL> create table dt_cons (constraint chk2 check(col2 IS NULL or col2>10))
      2  as select * from dt_pk3
      3  /
    create table dt_cons (constraint chk2 check(col2 IS NULL or col2>10))
                         *
    ERROR at line 1:
    ORA-00904: : invalid identifier
    
    SQL> create table dt_cons (col2 constraint chk2 check(col2 IS NULL or col2>10))
      2  as select * from dt_pk3
      3  /
    create table dt_cons (col2 constraint chk2 check(col2 IS NULL or col2>10))
                          *
    ERROR at line 1:
    ORA-01730: invalid number of column names specified
    
    SQL> create table dt_cons (id,col1,col2 constraint chk2 check(col2 IS NULL or col2>10))
      2  as select * from dt_pk3
      3  /
    
    Table created.
    
    SQL> desc dt_cons
     Name                                      Null?    Type
     ----------------------------------------- -------- ----------------------------
     ID                                        NOT NULL NUMBER
     COL1                                      NOT NULL NUMBER
     COL2                                               NUMBER
    
    SQL> insert into dt_cons values(2,2,2);
    insert into dt_cons values(2,2,2)
    *
    ERROR at line 1:
    ORA-02290: check constraint (JJACOB_APP.CHK2) violated
    
    SQL> insert into dt_cons values(2,2,10);
    insert into dt_cons values(2,2,10)
    *
    ERROR at line 1:
    ORA-02290: check constraint (JJACOB_APP.CHK2) violated
    
    SQL> insert into dt_cons values(2,2,11);
    
    1 row created.
    
    SQL> insert into dt_cons values(2,2,null);
    
    1 row created.
    
    SQL>
    

    HTH

    David

  • Alignment columnar with DataGrid problem

    Hi all.

    I have the following data grid:

    http://www.joshbeall.com/personal/Flex/Grid1.PNG

    If you filter some of the results with zeros in columns cited/applied, that's what you get:

    http://www.joshbeall.com/personal/Flex/Grid2.PNG

    See how the column heads are not aligned with the columns? Oddly enough, I still don't understand this behavior, but it often happens. If I click a column head (to change the sort order), the alignment is corrected.

    I have attached the full MXML for this application.

    BTW, another problem, I had (and have given up trying to hunt down is), why should I declare my WebService as < mx:WebService >, instead of simply do entirely in code? You can see in my MXML that I put in the comment a few lines of AS the initialization of the instance of WebService. I was originally, declaring and using my WebService entirely in code. However, data binding didn't work - the grid never filled. When I changed it to be declared as a < mx:WebService > tag, everything started working.

    -Josh

    Peter, I caught SDK build 180310/Wed Aug 22 2007 and that fixed the display problem.

    Rvollmar, thanks for the tip on [Bindable]. Add this attribute corrected the problem. You call the 'attributes' in ActionScript? 'attribute' is the name of .NET.

  • Invalid grid?

    Hello

    I have created a grid of ad-hoc using Smartview for the user and sent him the excel file. However, when she opens it, connected to the source of data and update, she is invited to "invalid grid... zero rows/columns...". Pls check delete options... ». She met the same even with grids that she created her own. Delete options aren't all verified. Did anyone come across the same front? Appreciate any advice. Thank you!

    DD

    Hi all

    It has proved to be an option under the "View" tab "Name of Member & Description.

    Thank you.

    David

  • Zero suppress

    In FDMEE where can I activate the zero power supress?

    I see this in the newspaper,

    ZP................ Zero suppress, amount field contains a value of 0 and zero suppress is running

    I want to create blocks in Essbse so a calc will produce correct results...

    Thank you

    PR

    Hello

    Follow these steps in the expression of import on the amount column Format. Add NZP as an Expression of the import by clicking on the pencil next to the amount on the Import Format screen and then add NZP.

    This admin guide talks too - just search for zero:

    http://docs.Oracle.com/CD/E57185_01/EPM.111 2/erpi_admin/Frameset.htm? Launch.html

  • Select only records where the column values are not all equal to zero

    Hi everyone, it seems so easy, but it has left me speechless on the research in a way that is clean, easy to achieve. I know when someone replies, I'm going to kick me. So, let's assume this is what I have:
    with mytable as (
    select 'Type 1' as itemtype, 'JAN' as monthname, 0 as theval from dual union all
    select 'Type 1' as itemtype, 'FEB' as monthname, 1 as theval from dual union all
    select 'Type 1' as itemtype, 'MAR' as monthname, 5 as theval from dual union all
    select 'Type 1' as itemtype, 'APR' as monthname, 1 as theval from dual union all
    select 'Type 1' as itemtype, 'MAY' as monthname, 4 as theval from dual union all
    select 'Type 1' as itemtype, 'JUL' as monthname, 0 as theval from dual union all
    select 'Type 1' as itemtype, 'AUG' as monthname, 0 as theval from dual union all
    select 'Type 1' as itemtype, 'SEP' as monthname, 1 as theval from dual union all
    select 'Type 1' as itemtype, 'OCT' as monthname, 7 as theval from dual union all
    select 'Type 1' as itemtype, 'NOV' as monthname, 1 as theval from dual union all
    select 'Type 1' as itemtype, 'DEC' as monthname, 2 as theval from dual union all
    
    select 'Type 2' as itemtype, 'JAN' as monthname, 0 as theval from dual union all
    select 'Type 2' as itemtype, 'FEB' as monthname, 0 as theval from dual union all
    select 'Type 2' as itemtype, 'MAR' as monthname, 0 as theval from dual union all
    select 'Type 2' as itemtype, 'APR' as monthname, 0 as theval from dual union all
    select 'Type 2' as itemtype, 'MAY' as monthname, 0 as theval from dual union all
    select 'Type 2' as itemtype, 'OCT' as monthname, 0 as theval from dual union all
    select 'Type 2' as itemtype, 'NOV' as monthname, 0 as theval from dual union all
    select 'Type 2' as itemtype, 'DEC' as monthname, 0 as theval from dual
    )
    select
      itemtype,
      sum (case monthname when 'JAN' then theval else 0 end) as JAN,
      sum (case monthname when 'FEB' then theval else 0 end) as FEB,
      sum (case monthname when 'MAR' then theval else 0 end) as MAR,
      sum (case monthname when 'APR' then theval else 0 end) as APR,
      sum (case monthname when 'MAY' then theval else 0 end) as MAY,
      sum (case monthname when 'JUN' then theval else 0 end) as JUN,
      sum (case monthname when 'JUL' then theval else 0 end) as JUL,
      sum (case monthname when 'AUG' then theval else 0 end) as AUG,
      sum (case monthname when 'SEP' then theval else 0 end) as SEP,
      sum (case monthname when 'OCT' then theval else 0 end) as OCT,
      sum (case monthname when 'NOV' then theval else 0 end) as NOV,
      sum (case monthname when 'DEC' then theval else 0 end) as DEC
    from mytable
    group by itemtype
    order by itemtype
    I need an external application around it or something which will select only 'Type 1'... that is, if all months are each equal to zero, do not include the record in the result set.

    In summary to get a total of zero is not an option, because I could have-15 and + 15 in different columns, in which case, the recording should be displayed.

    Something as simple as... 'not the case (oct = 0 and 0 nov and dec = 0...) at the end is all it seems to me necessary. I thought to add a case for each column clause, but that seems not very effective. Ideas?

    Thanks in advance!
    Mark

    Edit... I know not what follows will work using the MINUS operator, but my actual query is really huge, and I don't want to have to write it twice...
    {code}
    Select
    ItemType,
    sum (case monthname when "JAN" then Val else 0 end) such as JAN,.
    sum (case when monthname 'FEB', then Val 0 otherwise end) by Feb.
    sum (case when monthname 'MAR', then Val 0 otherwise end) like MARS,
    sum (case monthname when "APR" then Val else 0 end) as APR.
    sum (case when monthname 'MAY', then Val else 0 end) either.
    sum (case when monthname "JUN", then Val 0 otherwise end) as JUN.
    sum (case monthname when "JUL" then Val else 0 end) as JUL,.
    sum (case monthname when "AUG" then Val else 0 end) as AUG.
    sum (case monthname when "MS" then Val else 0 end) as MS.
    sum (case monthname when "OCTS" then Val else 0 end) OCT.
    sum (case monthname when "NOV" then Val else 0 end) as NOV.
    sum (case monthname when 'DEC' then Val else 0 end) as DEC
    FROM MyTable
    Group of itemtype

    less

    Select
    ItemType,
    Jan, Feb, mar, Apr, may, June, July, August, Sept, oct, nov, dec
    de)
    Select
    ItemType,
    sum (case monthname when "JAN" then Val else 0 end) such as JAN,.
    sum (case when monthname 'FEB', then Val 0 otherwise end) by Feb.
    sum (case when monthname 'MAR', then Val 0 otherwise end) like MARS,
    sum (case monthname when "APR" then Val else 0 end) as APR.
    sum (case when monthname 'MAY', then Val else 0 end) either.
    sum (case when monthname "JUN", then Val 0 otherwise end) as JUN.
    sum (case monthname when "JUL" then Val else 0 end) as JUL,.
    sum (case monthname when "AUG" then Val else 0 end) as AUG.
    sum (case monthname when "MS" then Val else 0 end) as MS.
    sum (case monthname when "OCTS" then Val else 0 end) OCT.
    sum (case monthname when "NOV" then Val else 0 end) as NOV.
    sum (case monthname when 'DEC' then Val else 0 end) as DEC
    FROM MyTable
    Group of itemtype
    )
    where (oct = 0 & nov = 0 and dec = 0 and jan = 0 and 0 = Feb and mar = 0
    apr = 0 and may = 0 and = 0 jun and Jul = 0 and aug = 0 and Ms = 0
    )
    order of itemtype
    {code}

    Change again... OK, I guess that I am answering my own question here, but I think that by using a WITH to write the main request once clause and then selecting * twice using the MINUS operator between where the second query is where (oct = 0, etc.) is what I need. If anyone has better suggestions, please let me know! Here's the logic of nickname for what I come up with to date...

    {code}
    WITH mainquery as (select all)
    Select * from mainquery
    less
    Select * from mainquery where (oct = 0, nov = 0, etc...)
    {code}

    Thanks again!
    Mark

    Published by: user455268 on March 1, 2012 19:13

    Published by: user455268 on March 1, 2012 19:16

    Hello

    You can do it with a HAVING clause:

    select
      itemtype,
      sum (case monthname when 'JAN' then theval else 0 end) as JAN,
      sum (case monthname when 'FEB' then theval else 0 end) as FEB,
      sum (case monthname when 'MAR' then theval else 0 end) as MAR,
      sum (case monthname when 'APR' then theval else 0 end) as APR,
      sum (case monthname when 'MAY' then theval else 0 end) as MAY,
      sum (case monthname when 'JUN' then theval else 0 end) as JUN,
      sum (case monthname when 'JUL' then theval else 0 end) as JUL,
      sum (case monthname when 'AUG' then theval else 0 end) as AUG,
      sum (case monthname when 'SEP' then theval else 0 end) as SEP,
      sum (case monthname when 'OCT' then theval else 0 end) as OCT,
      sum (case monthname when 'NOV' then theval else 0 end) as NOV,
      sum (case monthname when 'DEC' then theval else 0 end) as DEC
    from mytable
    group by itemtype
    HAVING      MIN (theval)     != 0
    OR      MAX (theval)     != 0
    order by itemtype
    ;
    

    If the values are all 0, then the MIN and MAX will be 0.
    If the MIN or MAX is not 0, the values are all 0.

    This assumes that the combination (itemtype, monthname) is unique, because it is in your sample data.
    If this is not the case, start with a subquery that GROUPs BY itemtype, monthname, so that when you get to the main request, this combination will be unique.

Maybe you are looking for

  • should what modules I?

    How can I check to see what modules I have already?

  • Halo 2 for vista doesn't work is not on the issue of Windows 7-live

    When I install Halo 2 and start the game, I get this message: Live gaming on Windows failed to initialize. Maybe it's because an another LIVE Gaming on Windows application (for example the dedicated server Halo 2) is running on the same computer. Oth

  • Director of Windows displays no video

    Original title: Windows movie maker problem While making a video with windows movie maker, the video worked perfectly fine, but now all of a sudden, the screen is black and will not play one of my videos. I edited a lot and I really want to do it aga

  • Working Group has missed! How can I remove the invader computer?

    I have a wireless home network connected through a Linksys wireless router.  A Vista, a XP laptop.  When my computer slowed last week I check the network and discovered another computer and multimedia device has been installed in my workgroup.  I sea

  • Simple PIX PIX VPN issues

    I'm trying to implement a simple PIX PIX VPN using the simple PIX - PIX VPN documentation for the sample config page. I have a lot of VPN tunnels with other very happy other PIX devices so it's quite annoying. Anyway, on the source PIX config is as f