Query to replace blank or null to zero

I have query as below
Select id from table1 where id =32
I dont have value in table1 for id=32.In this case i need to get a result like 0.Basically if nothing is there for that query it shoulh return 0.
of the query is like below
Select id from table1 where id in (12,32,10,42)
the result should be as below. There is no id for 32 and 42 so it should be 0
12
0
10
0
Please help

user10285699 wrote:
I have query as below
Select id from table1 where id =32
I dont have value in table1 for id=32.In this case i need to get a result like 0.Basically if nothing is there for that query it shoulh return 0.
of the query is like below
Select id from table1 where id in (12,32,10,42)
the result should be as below. There is no id for 32 and 42 so it should be 0
12
0
10
0
Please helpI used the with clause to generate data as i suppose you have it. In the future, providing this along with your version number is greatly beneficial for everyone involved in the process.
I have also used a generic Oracle Type, if you have your own feel free to use that (it's just a table of numbers) which we use to outer join to your data, whenever we cannot join (the outer join kicks in) we decode that NULL value to 0.
TUBBY?with your_data as
  2  (
  3    select 12 as id from dual union all
  4    select 10 from dual
  5  )
  6  select
  7    nvl(d.id, 0)
  8  from
  9    your_data                               d,
10    table(sys.odcinumberlist(12,32,10,42))  t
11  where
12    t.column_value  = d.id  (+);
       NVL(D.ID,0)
                12
                 0
                10
                 0
4 rows selected.
Elapsed: 00:00:00.10
TUBBY?

Similar Messages

  • How to replace  BLANK or NULL values in rule file

    Hi,
    I have a source file which contains Blank or Null values which i need to replace them with a number "042" .How we can do this in the rule file using "Replace "(Field->Properties).I tried keeping spaces but its failing. I am actually new to essbase please let me know how we can do this.
    Thanks in Advance

    Hi,
    Unfortunately you can't replace blank/null/space values directly. What you need to do is add a text field in your rules file first, then merge the text field with the column containing blank/null/space. Then you can use some creative find and replace to solve this problem.
    For example, I often add a column called "TextCleaner" to my rules files where I suspect b/n/s values. After merging there are 3 possible options for the value.
    1) "TextCleaner" (The original value was null)
    2) "TextCleaner " (The original value was space)
    3) "TextCleanerUSA Region" (The original value was valid data, such as USA Region)
    Now you can use the find and replace as follows
    First, F&R to remove any instance of "TextCleaner" and replace with 042. Be sure to check the "Match Whole Word" button. This swaps null values with 42
    Second, do the same thing but with "TextCleaner ". This swaps any space/blank values with 42.
    Third, replace "TextCleaner" with nothing. Do not check the "Match Whole Word" button. This changes any original valid values back to the original value.

  • Replace blank column values with ZERO

    Hi experts,
    I am building a report to display count of orders split by channel per day per hour.
    For some days one or few channels might not have any orders placed against them in which case my report shows blank values in the report.
    I would ideally like to have Zero in those columns rather than an empty cell.
    Sample Qry :-
    Select
    Channel,
    COUNT(order_num) as COUNT
    FROM
    SALES_ORDER
    Pls help !
    Thanks in advance.

    Try this code
    /* Formatted on 2009/05/11 07:53 (Formatter Plus v4.8.8) */
    SELECT   a.CLASS, a.order_date, a.time_created,
             NVL (a.count_orders, 0) AS count_orders
        FROM (SELECT   sales_order_header.soh_class AS CLASS,
                       TO_CHAR
                              (sales_order_header.soh_date_created,
                               'dd/mm/yyyy'
                              ) AS order_date,
                       SUBSTR
                          (TO_CHAR (sales_order_header.soh_time_created,
                                    'HH24:MI:SS'
                           1,
                           2
                          ) AS time_created,
                       COUNT (sales_order_header.soh_order_no) AS count_orders
                  FROM com.sales_order_header
                 WHERE sales_order_header.soh_date_created >=
                                             TRUNC (NEXT_DAY (SYSDATE, 'SUN'))
                                             - 14
                   AND sales_order_header.soh_date_created <
                                              TRUNC (NEXT_DAY (SYSDATE, 'SUN'))
                                              - 6
              GROUP BY sales_order_header.soh_class,
                       TO_CHAR (sales_order_header.soh_date_created, 'dd/mm/yyyy'),
                       SUBSTR (TO_CHAR (sales_order_header.soh_time_created,
                                        'HH24:MI:SS'
                               1,
                               2
              UNION ALL
              SELECT   sales_order_header.soh_own_id AS CLASS,
                       TO_CHAR
                              (sales_order_header.soh_date_created,
                               'dd/mm/yyyy'
                              ) AS order_date,
                       SUBSTR
                          (TO_CHAR (sales_order_header.soh_time_created,
                                    'HH24:MI:SS'
                           1,
                           2
                          ) AS time_created,
                       NVL
                          (COUNT (sales_order_header.soh_order_no),
                           0
                          ) AS count_orders
                  FROM com.sales_order_header
                 WHERE sales_order_header.soh_date_created >=
                                             TRUNC (NEXT_DAY (SYSDATE, 'SUN'))
                                             - 14
                   AND sales_order_header.soh_date_created <
                                              TRUNC (NEXT_DAY (SYSDATE, 'SUN'))
                                              - 6
              GROUP BY sales_order_header.soh_own_id,
                       TO_CHAR (sales_order_header.soh_date_created, 'dd/mm/yyyy'),
                       SUBSTR (TO_CHAR (sales_order_header.soh_time_created,
                                        'HH24:MI:SS'
                               1,
                               2
                              )) a
    ORDER BY a.order_date DESC, a.CLASS ASC

  • How can I change a blank value to a zero in a query?

    When displaying key figures I am getting blanks as opposed to zeros (if there is no data in the cube).  Does anyone know how to change the blanks to zeros?

    Hi,
    You can create a new Formula.
    In the Formula editor write:
    Formula = (Key Figure)+0
    your blank cells will  get 0 value
    Regards,
    MG.
    Edited by: MG . on Jan 18, 2008 1:43 PM

  • Replacing 'blank' with 0 in webreports

    Hallo,
    output of webreport conatins blank values when there is no data.after exporting to Excel also blank values remain unchanged.
    Can anybody tell me how to replace blank values with 0 in webreport output  or  having 0 instead of blank after exporting to excel.
    Rakesh.

    hi Rakesh,
    take a look steps in how to docs
    How to Hide a Column in your Web Query with the Table Interface
    https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/f0aca990-0201-0010-0380-f3aac4127a57
    How to Enhance your Web Query with the Table Interface
    https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/49dfeb90-0201-0010-a1a2-9d7a7ca1a238
    2.0B Web Reporting Table Interface.pdf
    https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/38e19090-0201-0010-cfac-f295b19b0424
    hope this helps.

  • Replace blank space

    Hi guys,
    ho wcan we replace blank space in obiee.
    i have applied if null function to replace with 0 but it is not workin .it may be a blank space so can we replace blankspace in obiee.

    We cannot replace null values from report.
    Another Solution:
    Go to column properties --> Conditional formating--->write the condition (IS NULL) --> Apply strikethough option in properties
    Hope this helps u
    Thanks
    Kishore

  • Load blank or null lines with SQL*Loader

    I want to retain blank (or null) lines present in the input file, which SQL*Loader retains. My control file looks like this:
    LOAD DATA
    INFILE 'c:\sdfload\compounds.sdf'
    BADFILE 'c:\sdfload\compounds.log'
    INTO TABLE sdfile
    ( rid "sdf_seq.nextval",
    sdfrec POSITION (1:600) NULLIF rid=BLANKS
    The first five lines of input look like (the blank lines look to be end-of-line or tab characters).
    Marvin 02171107552D
    38 43 0 0 0 0 999 V2000
    1.3379 -2.6605 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
    The output looks like this (first and third records excluded)
    RID SDFREC
    1 Marvin 02171107552D
    2 38 43 0 0 0 0 999 V2000
    3 1.3379 -2.6605 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
    How do I get output that looks like this?
    RID SDFREC
    1
    2 Marvin 02171107552D
    3
    4 38 43 0 0 0 0 999 V2000
    5 1.3379 -2.6605 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
    Any help or suggestions will be greatly appreciated!
    -Mike

    You might want to check an older post: SQL LOADER Insert Rows blank

  • In Derived column, make blank as null

    When I am using (Coulmn) == "" ? NULL(DT_WSTR,225) : Coulmn for making blank as null it is working fine.
    But it is making null as string, but I don't want to use null as string. As I am using Null in my stored procedure to load sub region data where "country is null".
    If I will use above expression of derived column it will make it as string which is not recommended in my case.
    Do you have any solution for it.
    Thanks
    Nidhi

    Whats the datatype you want column to be in? use corresponding NULL function.
    ie if string 
    NULL(DT_STR,20,1252)
    etc depending on what actual datatype of Country field is
    Please Mark This As Answer if it helps to solve the issue Visakh ---------------------------- http://visakhm.blogspot.com/ https://www.facebook.com/VmBlogs

  • Difference between Replacement with a query and Replacement from Variable

    Hi Gurus
    Would explain the difference between the Replacement Path: Replacement with a query and Replacement Path: Replacement from Variable with scenarios.
    Thanks in advance,
    Aravind.S

    Hi,
    If you are using Replacement with query, the given query output will be used as input your variable. For example if you want to display the product details, which can be find our from a query.
    And Replacement with Variable will be used  when you want to give the same input  in two different fields. for example if you want to see the records from sending location and not the records from recived location at the same time. Here once you give the sending location id, it will be taken as the same input for received location.
    Regards,
    Vishnu

  • Difference betwen Null item,Blank item ,item is zero and empty item

    Please describe the difference betwen :
    null item
    empty item
    blank item
    and zero item
    And how can we test each one?
    How to test if the value of an item say Px_y is null or
    blank
    empty
    zero
    Regards

    Please describe the difference betwen :
    null item
    empty item
    blank item
    and zero item
    And how can we test each one?
    How to test if the value of an item say Px_y is null or
    blank
    empty
    zero
    Regards

  • Replacing a Cell ( Entry) as ZERO - Characteristics in WAD View or Query le

    Hi,
    please let me know the following Requirement in a WAD View
    I want to filter a Master data entry ( Characteristic)
    Characteristc ( Created By)
         RAO
         RAMA
         SSR
         KRSNA
         AJAY
         RAO
         RAMA
         SSR
    I had a column shown above., i need to show a particular entry example RAO by using ZERO ( 0)., please let meknow how to do it in WAD level of BEx Query level.,
    Thanks!
    Rao S
    Edited by: Seelam  Rao on Nov 10, 2008 6:27 AM

    Michael,
    I am not sure if you can have icons outside the query that can be controlled by the query values. You could do one thing ...
    1. have a query with an extra Key figure.
    2. Have your validation formulae on this key figure and have an exception on the same
    3. Now your exception column would have three colors.
    4. Now execute the report in IE and go to view source.
    5. Look for the stylesheet classes for the exceptions , they would be something like SAPBexGood1... etc
    6. Go to the table interface ( I assume that you would have figured out how to inherit the class and modify the same from the how to paper...)
    7. Go to c_cell_data
    8. if cell_style="SAPBeXGood1" then replace c_cell_content with <img src="/sap/bw/mime/icons/icon1.gif" /img>
    9. Go to the css and find out your stylesheet class.
    10. Remove the background color attribute from the required style.
    for checking through JavaScript.
    1. The query should have a separate stylesheet class attached to it.
    2. It should have one cell only
    3. You can replace the value by using style.innerHTML=whatever you want.
    Hope this helps...
    Arun
    Assign points if found helpful
    Message was edited by: Arun Varadarajan

  • How to replace blank spaces with zero's in the report

    hai sdn guys,
                         we have a requirement where we cannot have any blank fields in the report and i need to replace the blanks with a zero. What is the best way to do it.

    Hi Sunitha,
    It is not proper that you are posting the same question multiple times:
    Re: report o/p should not have blank spaces in - in case of no value
    should get 0's in place of blank value in  the output of the report
    That too inspite of my requesting you not to do so.
    I am not sure if you have ever gone through the Rules Of Engagement which are prominently posted in each forum, but I think it is SDN courtesy to provide proper feedback when posting a question and assign points as deemed fit. This helps (and motivates) everyone to work on your problem and try to give you a solution. I hope you will be more careful in the future. Thanks!

  • Query Variable - Replacement Path

    Hi all,
    I would need to fill a query variable (based on calendar week characteristic) with specific list of values. I need all calendar weeks that are present in infocube, but only if key-figure > 0. So I've created a query with cal. weeks in rows and with suppressed zero rows. Output values from query contains exactly what I need.
    Than I created a variable (replacement path) with reference to mentioned query. But it seems to me that the variable does not contain all values displayed in the query, but only filtered values (if I use some restriction of cal. week).
    Is it possible to achieve this using replacement path at all?
    If not I would appreciate any idea or experiences how to accomplish this requirement.
    Many thanks,
    regards,
    Pavel

    Hi Pavel, I didn't get your requirement 100% . Still, I would like to tell How Replacement path works.
    First of all for the Source query you have given condition to restict the output of the query on particular keyfigure value > 0 ......  Right.
    Now on second query, you have created the Characteristic variable with Replacement path....here some important things to look at.
                    while creating the variable, select Processing Type as REPLACEMENT PATH, then in the "Replacement path" Tab,  give Replaced variable with.. "Query" ...and at bottom, For QUERY give the query name.
    If u want RRI facility from Source Query to Target Query, then u give RRI Connection in T-Code : RSBBS....
    ...and now when u execute the Second Query, First the first Query will be executed and those filtered values > 0 will be passed to the Second Query's variable input...then the second query will be executed...
    But, in your case check once again all settings in Variable in Second Query..and Conditions block in First Query..
    It should definitely work...
    ---Intros.
    Edited by: Intros on Apr 25, 2008 1:31 PM

  • How to replace blank values in DATE field with 00000000

    Hi
    I have a DSO with Date field in which there are blank values. I want to replace the blank values in the DSO for date field with 00000000. Because of this blank values in the DSO the report is giving an ORA error.
    How do we replace the blank values in the DSO for historical data and also the new loads?
    Please advise.
    Thank you.
    Regards,
    Pavan.

    Hi Suman,
    I'm trying to run a query built on a DSO. The DSO has a field 'Start Date'. This Start Date InfoObject has a reference Char as 0DATE.
    This Start Field has blank values due to which I'm getting the ORA-01722 error. I came across many threads with same topic of discussion. As mentioned in one of the Threads I have written a program to update 'Start Date' with 00000000. The code wriiten is "UPDATE /BIC/AZ_MONINV00 SET /BIC/ZSTR_DTE = '00000000' where /BIC/ZSTR_DTE = ' '.
    Now when I see the data in the active data table of DSO the blank value is replaced with '00000000'.
    But If I right click on the DSO click on display data the 'Start Date' field is blank. And now the Query also gets executed without any error. But in the output of the query the 'Start Date' Field has "#" values.
    Can anyone suggest on how to remove these "#" values in the report?

  • Apex changing nulls to zeroes when creating Flash Charts

    Hey all,
    Apex appears to be changing Null's to Zeroes when generating the XML to fuel a graph. I want to chart this year's output by month against last year's output by month. As this year is not complete, the two lines should be different lengths. When I view the XML, Apex is "filling in" the vacant (future) months with zeroes. This causes the line for this year to continue by dropping to zero for the rest of the year. I have already tried to adjust this by changing the maximum rows for this year's series.
    Any help would be greatly appreciated. Marco, this seems to be up your alley.
    Thanks.
    Paul

    Paul,
    The best place to put it is an Application Process.
    1) Go to Shared Components and create an Application Process (say it's named MY_CHART_XML_PROCESS). The PL/SQL for the Application Process should follow this general outline, substituting your own XML-generating logic for {my chart XML}:
    owa_util.mime_header( ccontent_type => 'text/xml', bclose_header => TRUE, ccharset => 'utf-8');
    htp.p('{my chart XML}');2) Replace both occurences of "FLOW_FLASH_CHART_R#REGION_ID#" with "APPLICATION_PROCESS=MY_CHART_XML_PROCESS" in the region source for the chart that is to use this XML.
    That should do it.
    - Marco

Maybe you are looking for

  • How do i take music from my Ipod and put back into my CPU.

    I lost some music files on my i tunes, but i still have all of these songs on my i pod. How do i take the music off my Ipod and put it back into my i tunes. I have a PC using windows XP. I lost a total of 1381 songs. I lost these song by trying to do

  • Dynamic For loop in Oracle 10g

    Hi , my requirement is to write dynamic for loop , Some thing similar to below plsql block, But I am getting error , please suggest declare lv_text varchar2(200); begin lv_text:='select * from some_table '; for i in (lv_text) loop null; end loop; end

  • SQL Loader Truncate and SQL TRUNCATE difference

    Could any one let me know what is difference between truncate used by control file of the SQL Loader and TRUNCATE command used by SQL? Is there any impact or difference of these both over the data files. Thanks

  • Allowing a user access to all calendars in his OU

    Hi Everyone. I have a hosted exchange environment (Meaning we have many little companies that buy mailboxes from us, and each one has its own OU under the main OU called Hosting.Local) One of our bigger clients has about 250 mailboxes in his OU, the

  • Billing document automatically archiving

    this is the error comming wen i m creating the billing and saving it its automatically archiving how to solve this issu please help if ned i ll provide more information.... Billing document 90000022 does not exist Message no. VF041 Diagnosis The bill