How to fill out a sparse table with zero

Hi all

I have a sparse table, most of the cells is null, but few of the cells is '1 '.

I would like to fill the null with zero.

This table is to rotate a transactional table into a table that describes the attributes and later for data mining


I think so

(1) make a user_tab_columns and copy / paste to make a script using NVL

for example

Select ' NVL('|| column_name ||) «, 0, » || column_name |'),' of user_tab_columns
where lower (table_name) = "claims_t1".

but I have a problem

for example

create or replace view claims_t2x
as
Select
NVL ("Diagnostic Imaging' _SPEC_SUM, 0," Diagnostic Imaging' _SPEC_SUM) 'Diagnostic Imaging' _SPEC_SUM
Of
claims_t1

I get the error ORA-00911: invalid character

as the name of the column got ' ' ' in there.



or

Use 2) PL/SQL


I just do a select and loop through all



For 2), I don't know how I can get all the column attribute.
As the attribute in the table operation is not fix so the number of column after swivelling isn't fix


any idea?


-Thank you very much for your comments.

Published by: xwo0owx on April 27, 2011 11:08

You can use nvl pivot by naming the values in quotes like that.

CREATE OR REPLACE VIEW emp_v1 AS
WITH pivot_data
     AS (SELECT deptno,
                JOB,
                sal
           FROM emp)
SELECT JOB,
       NVL ("10", 0) AS "10",
       NVL ("20", 0) AS "20",
       NVL ("30", 0) AS "30",
       NVL ("40", 0) AS "40"
  FROM pivot_data PIVOT (SUM (sal) --<-- pivot_clause
                                  FOR deptno --<-- pivot_for_clause
                                            IN (10, 20, 30, 40) --<-- pivot_in_clause
                                                               );

G.

Tags: Database

Similar Questions

  • How to fill out the "to:" line with a variable email address?

    I'm new to coding and am not sure how to ask my question. I have a link in an 'Email' symbol that I would like to have the window open to a 'mailto', but there are several instances of that symbol on the timeline, each using a different email address. If the [symbol]. Email.Click code reads as follows:

    Window.Open ('mailto:'+ sym.getVariable = ("emailWindow"), "_self")

    and the line in the Stage.creationComplete code that is supposed to call the variable code reads:

    sym.getSymbol("Details_David").$("Email").html ("[email protected]" "").setVariable("emailWindow","[email protected]");

    With this code, the browser opens a window of mailto, but the ' to: ' line readings, "indefinite".

    Either in the [symbol]. Email code. Click, I have:

    Window.Open('mailto:"emailWindow"',"_self")

    without the "emailWindow" as the variable name, the "to:" line to the mailto line reads, "emailWindow".

    How to fill out the "to:" line with a variable email address?

    Otherwise, it works better:

    1)

    replace

    sym.getSymbol("Details_David").$("Email").html ("[email protected]").setVariable("emailWindow", "mailto:[email protected]");

    with

    sym.getSymbol("Details_David").$("Email").html ("[email protected]");

  • How to fill out a FORM element with another element of FORM

    Hello

    I have a form element tell - item1...
    I entered some say - abc for item1 of value... As soon as the update is remote from item1, I want to fill another item2 with the value of item1 (abc).

    Thank you
    Deepak

    Deepak

    You can do this by using javascript.
    For item1 value "attributes of the HTML Form element.

    OnChange = $x (NAME_OF_ 'ITEM_TO_SET') .value = this value

    CITY

  • HOW TO FILL OUT FORM PDF WITH HEBROW ON CHROME?

    HOW TO FILL OUT FORM PDF WITH HEBROW ON CHROME?

    Chrome uses its own PDF Viewer (incompatible).

    Download the PDF file to your local drive, then fill it out of there with Adobe Reader.  Or use a browser that uses the Adobe PDF plugin.

  • How to fill out the customer type when you submit a form?

    How to fill out the customer type when you submit a form?

    You can't do right now in British Colombia by means of forms.

  • How to fill a field of date with today's date when the signature field is signed?

    How to fill a field of date with today's date when the signature field is signed? In the LCD, I insert a signature field and a date field, what parameters in these two fields are necessary to make this work? Is the date field, the value calculated? I tried different JS suggestions I found, but none work. In the form, I named the signature ClaimSignature field and the date in the ClaimSigDate field.

    The thought of her with a little help. In the script editor window, I selected the postSign event and added the following JS:

    Form1.Page1.ClaimSignature::postSign - (JavaScript, client)

    var date = new Date();

    var day = date.getDate ();

    var month = date.getMonth () + 1;

    var monthstring = (month, 10?) ('0' + month: month)

    year var = date.getFullYear ();

    var = year DateString + '-' + monthString + '-' + (day< 10="" "0"="" +="" day="" :="">

    ClsimSigDate.rawValue = dateString;

    I hope this helps someone else save time.

  • How to join this per_rating_levels this table with query table.

    Dear all,

    Guide how 2 join me per_rating_levels this table with query because, I want 2 see the per_rating_levels.name against all employees.
    When I join this table with query it shows several recording/cortion against this record.

    Query:

    SELECT
    PAPF.full_name employee_name,
    papf1.full_name supervisor_name,
    WOMEN'S WEAR. Employee_number,

    hr_general.decode_job (PAAF.job_id) job_name,
    Department of hr_general.decode_organization (PAAF.organization_id),
    PC.Name, PCE.Comments EmployeeComments,
    (by selecting pce1.comments in per_competence_elements pce1
    where
    PCE.assessment_id = pce1.assessment_id
    AND pce.competence_id = pce1.competence_id
    AND pce1.object_id = pce.object_id) ManagerComments;

    --(sélectionnez rtl.name dans rtl où les pc.) RATING_SCALE_ID = rtl. Name RATING_SCALE_ID)


    OF per_all_people_f women's wear.
    per_all_people_f papf1,
    per_all_assignments_f ADP,
    PA per_appraisals,
    pat per_appraisal_templates,
    per_assessments not,
    per_competence_elements pce,
    per_competences pc


    WHERE papf.person_id = paaf.person_id
    AND paaf.supervisor_id = papf1.person_id
    AND paaf.primary_flag = 'Y '.
    AND pa.appraisee_person_id = papf.person_id
    AND pa.appraisal_template_id = pat.appraisal_template_id
    AND pa.appraisal_id = pas.appraisal_id
    AND pat.assessment_type_id = pas.assessment_type_id
    AND pas.assessment_id = pce.assessment_id
    AND pce.object_id = papf.person_id
    AND pce.competence_id = pc.competence_id
    AND trunc (sysdate) BETWEEN papf.effective_start_date AND papf.effective_end_date
    AND trunc (sysdate) BETWEEN papf1.effective_start_date AND papf1.effective_end_date
    AND trunc (sysdate) BETWEEN paaf.effective_start_date AND paaf.effective_end_date

    - AND papf.employee_number =: p_employee_number
    - AND pa.appraisal_date =: p_appraisal_date
    - AND papf.business_group_id =: p_bg_id

    order of papf.employee_number


    Concerning

    user10941925 wrote:
    Dear all,

    Guide how 2 join me per_rating_levels this table with query because, I want 2 see the per_rating_levels.name against all employees.
    When I join this table with query it shows several recording/cortion against this record.

    '2' in your question means "to"? If so please do not use text instant message in this forum.

    Now I suppose that PRE_RATING_LEVELS is a table in your application. And you are trying to include this table in an existing query. But in doing so, you have found the Cartesian product, correct?

    In fact, how do you think someone a public forum without any knowledge of your table and data structure could help you?

    Lets see, here's your query. I formatted.

    
    select papf.full_name                                       employee_name
         , papf1.full_name                                      supervisor_name
         , papf.employee_number                                 employee_number
         , hr_general.decode_job(paaf.job_id)                   job_name
         , hr_general.decode_organization(paaf.organization_id) department
         , pc.name                                              name
         , pce.comments                                         employeecomments
         , (
              select pce1.comments
                from per_competence_elements pce1
               where pce.assessment_id = pce1.assessment_id
                 and pce.competence_id = pce1.competence_id
                 and pce1.object_id = pce.object_id
           )                                                    managercomments
      from per_all_people_f        papf
         , per_all_people_f        papf1
         , per_all_assignments_f   paaf
         , per_appraisals          pa
         , per_appraisal_templates pat
         , per_assessments         pas
         , per_competence_elements pce
         , per_competences         pc
     where papf.person_id           = paaf.person_id
       and paaf.supervisor_id       = papf1.person_id
       and paaf.primary_flag        = 'Y'
       and pa.appraisee_person_id   = papf.person_id
       and pa.appraisal_template_id = pat.appraisal_template_id
       and pa.appraisal_id          = pas.appraisal_id
       and pat.assessment_type_id   = pas.assessment_type_id
       and pas.assessment_id        = pce.assessment_id
       and pce.object_id            = papf.person_id
       and pce.competence_id        = pc.competence_id
       and trunc(sysdate) between papf.effective_start_date  and papf.effective_end_date
       and trunc(sysdate) between papf1.effective_start_date and papf1.effective_end_date
       and trunc(sysdate) between paaf.effective_start_date  and paaf.effective_end_date
    order
        by papf.employee_number 
    

    Now, you want to add the PRE_RATING_LEVELS in the list so that you can use the column NAME.

    First thing you need to do is to determine the relationship between PRE_RATING_LEVELS and other tables. A relationship can be

    1. one on one
    2 one-to-many
    3. - to-several

    So when you tried to join, your state of health has resulted in 2nd or 3rd type of relationship. If you arrive with someone who knows the business and the data and find the table that could uniquely identify a line of PRE_RATING_LEVELS.

  • BAD RESULTS WITH OUTER JOINS AND TABLES WITH A CHECK CONSTRAINT

    HII All,
    Could any such a me when we encounter this bug? Please help me with a simple example so that I can search for them in my PB.


    Bug:-8447623

    Bug / / Desc: BAD RESULTS WITH OUTER JOINS AND TABLES WITH a CHECK CONSTRAINT


    I ran the outer joins with check queries constraint 11G 11.1.0.7.0 and 10 g 2, but the result is the same. Need to know the scenario where I will face this bug of your experts and people who have already experienced this bug.


    Version: -.
    SQL> select * from v$version;
    
    BANNER
    --------------------------------------------------------------------------------
    Oracle Database 11g Enterprise Edition Release 11.1.0.7.0 - 64bit Production
    PL/SQL Release 11.1.0.7.0 - Production
    CORE    11.1.0.7.0      Production
    TNS for Solaris: Version 11.1.0.7.0 - Production
    NLSRTL Version 11.1.0.7.0 - Production

    Why do you not use the description of the bug test case in Metalink (we obviously can't post it here because it would violate the copyright of Metalink)? Your test case is not a candidate for the elimination of the join, so he did not have the bug.

    Have you really read the description of the bug in Metalink rather than just looking at the title of the bug? The bug itself is quite clear that a query plan that involves the elimination of the join is a necessary condition. The title of bug nothing will never tell the whole story.

    If you try to work through a few tens of thousands of bugs in 11.1.0.7, of which many are not published, trying to determine whether your application would be affected by the bug? Wouldn't be order of magnitude easier to upgrade the application to 11.1.0.7 in a test environment and test the application to see what, if anything, breaks? Understand that the vast majority of the problems that people experience during an upgrade are not the result of bugs - they are the result of changes in behaviour documented as changes in query plans. And among those who encounter bugs, a relatively large fraction of the new variety. Even if you have completed the Herculean task of verifying each bug on your code base, which would not significantly easier upgrade. In addition, at the time wherever you actually performed this analysis, Oracle reportedly released 3 or 4 new versions.

    And at this stage would be unwise to consider an upgrade to 11.2?

    Justin

  • How to fill out (display) values for several blocks in which there is no relationship between the blocks (tables).

    Hello.

    Is it possible to fill in the values (execute_query) several blocks where there is absolutely no relationship between the tables in the same form?

    There is no relationship between the tables. All are separate tables with different columns. None of the names of columns match

    & also the values of the columns do not match. I created blocks for all tables. When I click on run, only the first block of values (first picture) is filled.

    other values of block did not get filled. Is it possible to fill in the values for all of the blocks where there is not relationship, or when there is no master block?

    Is there something I can do for this? It is mandatory for me to put all the blocks in a single form.

    Help me, please. Please do not respond.

    Thank you.

    Create a key-EXEQRY-trigger on the block where 'throw you' the quers. In it, put something like

    GO_BLOCK ('BLOCK1');

    EXECUTE_QUERY;

    GO_BLOCK ('BLOCK2');

    EXECUTE_QUERY;

    ...

  • How to fill out the list of dynamic measurements

    Hello

    I create a dynamic action on a region by using a select list (item) (lov on table A).

    now the problem is that if the value in the selection list is present in the table B then must trigger the action.

    can someone tell me how to fill the column of values as the values in table B.

    I don't want to set the values manually.

    Thank you
    Little Foot

  • You can create a hidden page element that acts as an indicator of the condition "exists."
  • Create a D.A. say 'Set Hidden Page Item"that fires on the element of change o selection list, which is of type 'set Value' and uses a function body PLSQL to set the hidden page (the affected item) item, choose the item of list selection in the field 'referred to submit page '.
    Now the PLSQL block, can return 1/0 'TRUE' or 'FALSE' or 'Y' / ' not etc. Depending on whether the record exists in the other table (or whatever condition you have)

    Now when the selection list is changed, the hidden element would be set correctly by using this dynamic Action.

    So, to check if the element exists, we can use the value of the element of hidden after that page.

    You can do this either as another action True under the dynamic Action of "Set Hidden Page Item" itself (after the action SetValue True) and added a condition using the value of the hidden element
    or add another dynamic Action, fired when the hidden item is changed and when the value of the hidden element corresponds with that of your conidtion.

    Hope that I was clear enough.

  • How to fill a hidden form field with a value passed in another page

    I use PHP/MySQL and DW CS4.

    I'm trying to get the foreign key to a table and include it in a hidden field in a form to another table.

    The user selects a 'need' to a list and is taken to a new page that displays the need selected in the previous page and a form that the user can fill out with details of its offer, there is also a hidden field in the form that contains the index to the table needs, this hidden field retains the external key. Most of the code works, except to fill the hidden field with the external key. I proved (by printing it on the screen) that I got the external key and stored in a variable ($saveNeedId). I am unable to do so, what affect this variable in the hidden field in the form, I'm about to be stored in a table. Sometimes, I have zero and sometimes I get the index of the first necessity in the table. It should be simple but I can't make it work, I must be missing something obvious - still very new to PHP.

    The following code sets the variable and display for test purposes

    $saveNeedId = "-1";
    If (isset($_GET['needId'])) {}
    $saveNeedId = $_GET ['needId"];
    print $saveNeedId;
    }

    Here is the code that implements the fields hidden in the form, where I'm putting in place is the first one, needId

    < input type = "hidden" name = "needId" value = "<?" PHP echo $row_rsNeedsUnmet ["needId'];? ">" / >
    < input type = "hidden" name = "offerId" value = "" / > "
    < input type = "hidden" name = "MM_insert" value = "form1" / >

    The page where the user sees the list of needs is here www.hollisterairshow.com/weneed.php

    I would really appreciate sone help with this, I tried all combinations of double quote, percent sign and nothing works... sigh.

    Tony

    The following code sets the variable and display for test purposes

    $saveNeedId = "-1";
    If (isset($_GET['needId'])) {}
    $saveNeedId = $_GET ['needId"];
    print $saveNeedId;
    }

    Here is the code that implements the fields hidden in the form, where I'm putting in place is the first one, needId


        
        

    I looked at your page. It seems that you have thought about it.

  • How can I set up a table with a fixed header on parchment?

    I'm trying to implement a table with a fixed header on parchment on my site of Muse. The table must scroll with main site window (not inside a box).

    Here is an example with CSS, HTML and JS code in separate windows.

    Is this achievable in Muse? If so, how can it be done?

    I saw a few threads on similar topics but have not found an answer.

    Thank you.

    Dmitry

    Yes, you can add the table by using the feature to insert the HTML code and it will still work until browsers stop supporting them. But you will not be able to pin, added the header of the table in the order of the Muse.In, to pin header in the Muse, it must be a separate object in the Muse.

    If you need to do requires a significant amount of custom coding, then Dreamweaver is probably a more appropriate tool as Muse does not support direct access to the code.

  • How to export data from the table with the colouring of cells according to value.

    Hi all

    I use jdeveloper 11.1.1.6

    I want to export data from the table with a lot of formatting. as for color cells based on value and so much. How to do this?

    You can find us apache POI-http://poi.apache.org/

    See this http://www.techartifact.com/blogs/2013/08/generate-excel-file-in-oracle-adf-using-apache-poi.html

  • How to match columns from two tables with

    Hello:
    I have two tables as below:

    Table1::(Base Table)
    Country | Prefix | Prefix_Length
    Travel | 001 | 3
    CountryB. 0012 | 4
    PaysC | 00443 | 5
    CountryD | 0091 | 4

    :(Detail Table) table2
    The population | Area | Prefix
    500 | AreaA | 0015921
    1000 | AreaB | 00122
    400. AreaC. 00443743
    300. ALIS | 0091333
    100. AreaA | 001

    I need to match these two tables with prefix columns (whose length is not fixed in the two tables: but it starts with 00 in the two tables). Two different countries the prefix may be similar up to a certain length. Thus, Prefix_Length can be used to determine (exactly) how much time should be taken in the search of Table2.

    Output:
    Country | Prefix | Area | Population
    Travel | 001 | AreaA | 600
    CountryB. 0012 | AreaB | 1000
    PaysC | 00443 | AreaC. 400
    CountryD | 0091 | ALIS | 300

    Please help me with your valuable comments.

    -Tender

    Try this

    with base_table as (
                        select 'CountryA' country,'001' prefix,3 prefix_length from dual union all
                        select 'CountryB','0012',4 from dual union all
                        select 'CountryC','00443',5 from dual union all
                        select 'CountryD','0091',4 from dual
                       ),
       detail_table as (
                        select 10 no_of_call,'0015921' prefix from dual union all
                        select 3,'00122' from dual union all
                        select 50,'00443743' from dual union all
                      select 50,'00443643' from dual union all
                        select 300,'0091333' from dual union all
                        select 60,'001' from dual
                       ) 
    
    SELECT  country,
            prefix,sum(no_of_call)
       FROM (
             select  country,
            b.prefix,no_of_call,
            decode(no_of_call,lead(no_of_call,1,0) over(partition by no_of_call order by b.prefix,no_of_call),'y','n') y_or_no
      from  base_table b,
            detail_table d
      where b.prefix = substr(d.prefix,1,prefix_length))
      where y_or_no !='y'
      group by  country,
            prefix
      order by country,
            prefix;
    

    Published by: Vi on 20 February 2012 01:07

  • How to fill out a police dig?

    I use a block style font that is hollow.  Is that you can see through it to what is below it.  How I fill it with a solid color?  I tried the overlay color, but it colors the "black" part of the police.  Obviously, I don't want to Fill-in parts that should not be, for example, (the center of the letter 'o').

    Thank you.

    Make an empty layer above the text layer. On the text layer, click on the hollow spaces with the magic wand. On the empty layer, fill it with the color.

Maybe you are looking for