How to suppress records that contain zero values

Dear folks,
Please take a look at my query below. This is a sample query with only 6 columns but my actual query has about 70 columns. Basically I need to be able to suppress those rows where numerical values are zeros across a row. But even if one column has a value greater than zero, I need that row. Is there any better way to do it or this is the only way to do it? I am just trying to avoid creating a big WHERE clause with all fields in there. Kind regards.
with my_table as (
Select 'A' as org, 12 as val_1, 13 as val_2, 14 as val_3, 40 as val_4, 100 as val_5 from dual
union all
Select 'b' as org, 12 as val_1, 13 as val_2, 14 as val_3, 40 as val_4, 100 as val_5 from dual
union all
Select 'c' as org, 12 as val_1, 13 as val_2, 14 as val_3, 40 as val_4, 100 as val_5 from dual
union all
Select 'A' as org, 0 as val_1, 0 as val_2, 0 as val_3, 0 as val_4, 0 as val_5 from dual)
select * from my_table
where
( val_1 != 0 And val_2 != 0 and val_3 != 0 and val_4 != 0 and val_5 != 0)

Hi,
dreporter wrote:
Dear folks,
Please take a look at my query below. This is a sample query with only 6 columns but my actual query has about 70 columns. Basically I need to be able to suppress those rows where numerical values are zeros across a row. But even if one column has a value greater than zero, I need that row. Is there any better way to do it or this is the only way to do it? I am just trying to avoid creating a big WHERE clause with all fields in there. Kind regards.Sorry, I don't know of any way to avoid referencing each column by name.
The fact that you want to do this hints that this is a denormalized table, designed to make coding difficult and inefficient. A better design would be:
SELECT 'A' as org, 12 as val,  1 AS col_num     FROM dual  UNION ALL
SELECT 'A',           13,            2              FROM dual  UNION ALL
SELECT 'A',        4,            3          FROM dual  UNION ALL
SELECT 'A',        40,            4          FROM dual  UNION ALL
SELECT 'A',         100,            5          FROM dual  UNION ALL
...Then you could use the MAX function to see if any of them were greater than 0, regardless of how many there were.
with my_table as (
Select 'A' as org, 12 as val_1, 13 as val_2, 14 as val_3, 40 as val_4, 100 as val_5 from dual
union all
Select 'b' as org, 12 as val_1, 13 as val_2, 14 as val_3, 40 as val_4, 100 as val_5 from dual
union all
Select 'c' as org, 12 as val_1, 13 as val_2, 14 as val_3, 40 as val_4, 100 as val_5 from dual
union all
Select 'A' as org, 0 as val_1, 0 as val_2, 0 as val_3, 0 as val_4, 0 as val_5 from dual)
select * from my_table
where
( val_1 != 0 And val_2 != 0 and val_3 != 0 and val_4 != 0 and val_5 != 0)That shows the rows where ALL 5 of the columns are not 0.
If you want the rows where AT LEAST 1 of the columns are not 0, then use OR instead of AND.
!= means not equal to 0. You said you were interested in whether the columns were greater than 0, which is >=.

Similar Messages

  • How to transfer database table contain null values, primary key, and foreign key to the another database in same server. using INSERT method.

    how to transfer database table contain null values, primary key, and foreign key to the another database in same server. using INSERT method.  thanks

    INSERT targetdb.dbo.tbl (col1, col2, col3, ...)
       SELECT col1, col2, col3, ...
       FROM   sourcedb.dbo.tbl
    Or what is your question really about? Since you talke about foreign keys etc, I suspect that you want to transfer the entire table definition, but you cannot do that with an INSERT statement.
    Erland Sommarskog, SQL Server MVP, [email protected]

  • Supress Missing Blocks : Suppressing rows that contains data

    Hi,
    In Hyperion Planning 11.1.2.2, on a webform if I do supress missing blocks, it suppresses rows that contains data also (for 3 particular members of the dimension selected in the row).
    This webform is otherwise a huge report & if I do not check on supress missing blocks, the application hangs on trying to open this report (webform).
    Summarizing, on selecting supress missing blocks, it should bring me data for 90 members but it is currently displaying results for 87 members.
    Thanks in Advance.
    Pawan.
    [email protected]__

    Are you definitely sure there are no blocks for those members, maybe there is data but it is just set as #missing and the blocks have not been removed.
    Cheers
    John
    http://john-goodwin.blogspot.com/

  • How to Display WBS's with Zero values in a report created by CJE2

    Hi All,
    I have created a report using CJE1 (Report painter). When I execute the report, it only shows WBS that have values. How do I display WBS elements that do NOT have values? i.e. display items with zero values. I'm certain there is a setting either within report painter or forms...
    Help appreciated.
    Samir

    Menu>Formatting>Report Layout and then tab Rows. Check if setting under 'Treatment of zero rows' helps.
    Regards
    Sreenivas

  • E4X : How to get elements that contain a string pattern in the node name?

    Is there a way to extract children from an XMLList where the node name of a child contains a string pattern?
    For example :
    <record>
         <XblahX/>
         <cow/>
         <YblahY/>
    </record>
    How to get the elements of record that have a node name that contains the string "blah"?

    var rec:XML = <record>
         <XblahX/>
         <cow/>
         <YblahY/>
    </record>;
    var r:RegExp = /blah/;
    var elems:XMLList = rec.children().(localName().search(r)>-1);
    trace(elems.toXMLString())

  • How to store records that are entered in the fields?

    Hi friends can any one help me how to store the records that are given as input.
    Say if Empid - 123456, this 123456 has to be stored in table it will be stored but can any one help me with procedure?
    Thanks

    Hi,
    If the records are from an input file, you will have to first create a structure for the Employee id ....
    then, read the input file data into the internal table you have defined in the earlier step...
    then, loop at the records one after the other and update the records directly into the table....( typically this is a direct update of data and will be done when you were dealing with the data relating to a "Z" table )
    please follow the procedure and let me know how it worked for you or if you are still having issues on this.
    Thanks,
    Vishnu.

  • How to display records that match user input date

    hi all,
      i need to display records that match user input date (i.e., for example if the difference between user input date and record date is less than 5 years then display those records) , this is for hr bw. any exit is there to check for validation for records to be displayed based on some abap coding.
    vijay

    I just see getApplication method but "Retrieves a list of all the deployed applications."
    My scenario is: I get user, end i want to discorver how application this user i enable to see.

  • Visio Drawing Using Data Graphics with data that has a field that contains Multiple Values.

    I am working on creating a drawing for SMTP connectors.  I decided I would use a Data Graphic connecting to a spreadsheet.  In the spreadsheet there are a few fields that are Multi-Value fields.  For instance SmartHosts contains multiple Ip
    address.  I am trying to get this to format things so that the IPs show on the next line down instead of continuing on the same line until it wraps. 
    Does anyone know a way I could do this?
    Jeff C

    Hi Jeff,
    Arrange the IP values in spreadsheet using Alt+Enter (Use this key pair as a separator between two IP values). Now link this spread sheet to Visio. The values should appear in the same manner in data graphics as your expectation.
    Let me know if you meant something else.
    Thanks,
    Dheeraj 

  • How do i record that i made a dvd to my macbook pro?

    how do i record a dvd that i made to my macbook pro,and edit it?

    Your question is very vague. Please fill in the details...

  • Session variables that contain echo values

    I am looking for a system/session variable that would contain the values echoed back from oracle such as in sql+. What I am attempting to do is create a procedure that will return the number of row updated or any information return through an update statement using set processing?

    sql%rowcount will give you that:
    sql>begin
      2  update emp set ename = lower(ename);
      3  dbms_output.put_line(sql%rowcount);
      4  end;
      5  /
    14
    PL/SQL procedure successfully completed.

  • How To Suppress Records In Subreport Based on Value in Main Report

    I want to supress records in the Details section of my subreport based on a value in the Details of my Main report (main report could have same record as subreport).
    I created the following formula with a shared variable and placed it in the Details section of my main report:
    WhilePrintingRecords;
    Shared StringVar sCertCode :={ACCPASCERT.CERT_CODE}
    I placed the subeport in the Group Footer of the Main Report.
    In the subreport, in the Section Expert I added the following formula for Supress of the Details section:
    WhilePrintingRecords;
    Shared StringVar sCertCode;
    sCertCode = {ACCJBCERTS.PERS_CODE}
    Unfortunately even though the value in the main report is the same as the value in the subreport, those records are not being suppressed in the subreport.
    Would appreciate any ideas.
    Thanks.

    Thanks Zilla.
    The group is not based on Cert_Code but on another database field.
    I can try linking on the Cert_Code. But, how do you make the link "<" ">" when linking the main report and the subreport. I don't see that as an option?
    Edited by: Giulia Smyth on Feb 27, 2009 4:05 PM

  • How to suppress records with vzero value in a union report in OBIEE?

    Hi
    I have a Union report ,Rep1 union Rep 2,with a cloumn A in rep1 and a dummy column in place of column A in rep 2.
    I want to restrict the records where A= 0 in the union report.
    How to go abouth this.
    Thanks in advance !!

    hi,
    In report1 let the column be as it is ,why are you changing the f(x) to case statement.Did you check is data there in that column of report1.
    In the union report make tat dummy column as 0 or 1 accordingly as per your requirement.So it would retrieve all the values of column of report1.
    Check the join conditions established and play with the joins like give a full outer join and check if the data is coming including 0's if so then you can pply filter on that column saying column not equal to 0,so the remaining values gets populated.
    Cheers,
    KK
    Edited by: Kranthi.K on May 18, 2011 2:03 AM

  • How to handle the records that contain different number of columns

    hi all,
    I have a file (as source data)includes order information like:
    H,P001,Smith,Sunnyvale
    D,P001,PR97623,150,10.99,Ice cream
    D,P001,PR33267,45,32.66,Popcorn
    T,P001
    H,P003,Williams,San Jose
    X,P003,PR23563,19,25.54,Peanuts
    T,P003
    I want to transfer the file record to three target tables,
    the record marked "H" to "Summary" table and sum money of the detail
    the record marked "D" to "Detail" table
    the record marked "X" to "Error" table
    the expect result as below:
    Summary table
    Order_No Customer Address Total_Money
    P001 Smith Sunnyvale 3118.2
    (※3118.2=150*10.99+45*32.66)
    Detail table
    Order_No Prodcut_Id Prodcut_Name Quantity Price
    P001 PR97623 Ice cream 150 10.99
    P001 PR33267 Popcorn 45 32.66
    Error table
    Head Order_No Record_No
    X P003 6
    (※6 is the line no in the file)
    How can I do this in ODI , could anyone give some hints?

    Hi AGUI,
    You can do this by the following way,
    1) create the File datastore for the file with 6 columns
    while creation select the following option file format as Delimited
    record seperator as MS-DOS and field sep as other specify "," in the text box.
    -- check the file datastore maps correctly by view the data.
    2) create the interface int1 for transfer the data from this file to temp table( the temp table should have one more column for getting the line number( it should be the sequence number).
    3) create the another interface int2, in this interafce you need to transfer the data from the[b] temp table to Detail table (use filter for gatting D record.
    4) create the interace int3 transfer the data from the temp table to Summary table. please keep the total_money field as null for this interace
    and use Odi procedure for updating this field with reference of details table.
    5) create interface int4 for transfer the error date by transferinf from temp table to error table.
    Thanks,
    Madha

  • How do I record a numeric output values and then use them?

    So at the moment I just have a numeric value being display with a numeric indicator. I want to record this value somewhere for later use. Such as doing calculations. I want to store many numeric values that are outputed to this single indicator at different times and then pull them from the stored place and use them. I don't know much about arrays and storage stuctures in labview.  Can someone give me some directions please? Thanks

    So there isn't really anything related to the question yet in may code.
    My code shows movement control for a motor.
    I have a forwards button which increments +1 for every iteration of the loop. Each loop sends a pulse to the motor to move it.
    I have a backwards button which increments -1 for every iteration of the loop. In this loop i have just placed the direction pulse which tells the motor to turn the oposite way.
    these increments add onto a counter which is shown as the numerical indicator, used to show the position of the motor.
    I also have a reset button on this motor. To change the position to zero.
    So now what i want is to put the value of the position of the motor into an array which will then stay at that value in the array even when the position moves again. So i can record different positions.
    I then want to use these values. so i want to know how to get them from the array to the Number of iterations for a For loop so i can move the motor by that amount.
    Your help is appriciated, ive already spent so much time getting to this stage.
    Attachments:
    Xaxisbutton.vi ‏15 KB

  • How to validate string that contains special characters.

    Hi,
    I am new to Data Services.I took excel sheet as a data source .Now i have do some validation functions like vendorgroup should not contain special characters ,name cleansing operations etc.. So,please anyone help me redarding this.
    Thanks in advance

    Anonymous,
    No this is not a bug. Working with multi-select lists or any item which stores colon delimited values can be tricky to work with in APEX. There are a few work arounds for this. One is to replace the colons with something else like you described and then replace the colons on the landing page. Another solution is to send the primary key for that record and have an automatic row fetch or a computation pull the colon delimited value.
    Cheers,
    Tyson Jouglet

Maybe you are looking for

  • Ipod causes Windows Vista to stutter

    Hi, I have recently upgraded to Vista and when i plug my ipod in, it causes my system to slow to a crawl and stutter, mouse moves really slowly, things take ages to action. I had this problem when i installed my USB hard drive, but that seemed to cur

  • Icant installed itunes on windows 7 64 bits

    how can a install itunes en windows 7 64 bit

  • Xml or mysql?

    Hello, i've made a few simple java games that i've placed on my website and i want to add high score lists to them. I was hoping to get some opinions on the best method to something like this. is it possible to use JDBC with one of my databases? or s

  • ORA-01722 happen when using the cursor

    This is my cursor declaration: CURSOR cP_PROFILE_SKU_ID(pBusiness_partner_id IN BUSINESS_PARTNER.BUSINESS_PARTNER_ID%TYPE, pClient VARCHAR2 ) IS SELECT record_id FROM pending_changes WHERE UPPER(field_name) = 'BUSINESS_PARTNER_ID' AND UPPER(table_nam

  • Data display

    Hi, When user runs the report R5800073 (Ver WAL0001) for the document number 338405,he will get the csv output,In the CSV output, there is one column problem details2 in which data is appearing in the second line instead of appearing in the current l