How to flatten rows

Hi All,
I am trying to build a fact table.
The fee snapshot table is as follows
id,
date,
expense_type_cd,
cost_type_cd,
cost_life_cycle_cd,
fee_amt
My fact tables has columns like amt1,amt2,amt3,amt4,amt5
amt1= fee_amt from fee snapshot table where expense_type_cd in (x,y) and cost_type_cd in (q)
amt2= fee_amt from fee snapshot table where expesene_type_cd in (y)
amt3= fee_amt from fee snapshot table where cost_life_cycle_cd in (z)
create table temp as
select id, expense_ty_cd,cost_ty_cd, cost_life_cycle_cd, sum(fee_amt) amt
from fee_snpsht
group by id,rollup(expense_ty_id,cost_ty_cd,cost_life_cycle_cd)
the amounts are based on different combinations of there is no fixed combination
I created a temp table and calculated the amts using cube and rollup functions..but my question here is, to populate each and every column, do i need to write a subquery on the snapshot. i.e
insert into fact_table
(id,amt1,amt2,amt3,)
select
a.id,
(select fee_amt from temp where expense_ty_cd in(x,y) and cost_type_cd in (q) and temp.id=a.id) amt1,
(select fee_amt from temp where expense_ty_cd in(y) and cost_life_cycle_cd in (q,x,y) and temp.id=a.id) amt2,
(select fee_amt from temp where cost_type_cd in (q) and temp.id=a.id) amt3,
from fee_snapshot a
I have 20 such amount fileds. So for every amt field do I need to access the table in the above way or is there an efficient way to do this?
Please let me know i did not make sense.
your help is greatly appreaciated.
Thanks
Haro

You can do it directly. NOT TESTED !
Just to convey the idea clearly
select id,date,sum(fee_amt) fee_amt
  from fee_snpsht
where instr(:expense_type_cd,expense_type_cd) > 0
   and instr(:cost_type_cd,cost_type_cd) > 0
   and instr(:cost_life_cycle_cd,cost_life_cycle_cd) > 0
group by idif the expense_type_cd,cost_type_cd and cost_life_cycle_cd values are not varchar2(1) you must change all instr to (comma as list separator assumed)
instr(',' || :cost_type_cd || ',',',' || cost_type_cd || ',') > 0you must also set up a what does stand for any_value (null in this example)
instr(',' || nvl(:cost_type_cd,cost_type_cd) || ',',',' || cost_type_cd || ',') > 0something to play with:
select id,date,sum(fee_amt) fee_amt
  from fee_snpsht
where instr(',' || nvl(:expense_type_cd,expense_type_cd) || ',',',' || expense_type_cd || ',') > 0
   and instr(',' || nvl(:cost_type_cd,cost_type_cd) || ',',',' || cost_type_cd || ',') > 0
   and instr(',' || nvl(:cost_life_cycle_cd,cost_life_cycle_cd) || ',',',' || cost_life_cycle_cd || ',') > 0
group by idRegards
Etbin

Similar Messages

  • How to get row number of selected entry from OVS search result

    Hi,
    Anyone having any idea on how to get row number of the  selected entry/ how to differentiate rows in OVS search result in ON_OVS method?
    Regards,
    Jatin

    Hi,
    You can get the selected record to <ls_selection> structure in co phase 3.
    From that structure you can get what ever field you want.,
    check the below code for reference,
    << Moderator message - Cut and paste response from F4 help for ALV table field removed. Plagiarism is not allowed in SCN >>
    hope this helps u.,
    Thanks & Regards,
    Kiran
    Edited by: Rob Burbank on Jan 5, 2012 5:24 PM

  • How to delete rows in the target table using interface

    hi guys,
    I have an Interface with source as src and target as tgt both has company_code column.In the Interface i need like if a record with company_code already exists we need to delete it and insert the new one from the src and if it is not availble we need to insert it.
    plz tell me how to achieve this?
    Regards,
    sai.

    gatha wrote:
    For this do we need to apply CDC?
    I am not clear on how to delete rows under target, Can you please share the steps to be followed.If you are able to track the deletes in your source data then you dont need CDC. If however you cant - then it might be an option.
    I'll give you an example from what im working on currently.
    We have an ODS, some 400+ tables. Some are needed 'Real-Time' so we are using CDC. Some are OK to be batch loaded overnight.
    CDC captures the Deletes no problem so the standard knowledge modules with a little tweaking for performance are doing the job fine, it handles deletes.
    The overnight batch process however cannot track a delete as its phyiscally gone by the time we run the scenarios, so we load all the insert/updates using a last modified date before we pull all the PK's from the source and delete them using a NOT EXISTS looking back at the collection (staging) table. We had to write our own KM for that.
    All im saying to the OP is that whilst you have Insert / Update flags to set on the target datastore to influence the API code, there is nothing stopping you extending this logic with the UD flags if you wish and writing your own routines with what to do with the deletes - It all depends on how efficient you can identify rows that have been deleted.

  • How to implement row level security?

    Hi all,
    There is a database which is for 3 companies to use it and how to use row level security to make sure that they can only manipluate their own data? For example, "employee" table, for each company they just can see their own employees information. How to use dynamic view to do it?
    Many Thanks
    Amy

    Here are two options to achieve what you want.
    A. You can do this by coding, that's if you are ready to. Are you? If yes then try the steps below:
    1. create a security codes table. Say for example
    001 - company a
    002 - company b
    2. create a security table that will list all users and which company they should have access to. You can also implement this by roles.
    3. alter all tables in the application schema to add a security code column. This will be a foreign key reference to table created in 1 above.
    4. update all data in the tables according to which company they belong to.
    5. write a procedure or package that does a validity check whenever a user requests for data. This procedure/package determines which company data the user has access/rights to.
    With this, you should be able to achieve what you want if you do not want to spend on VPD and FGAC. The problem comes where there are users who would have cross access to data from both companies. In this regard, then you have to modify your security table a little bit to handle this.
    B. This option i will admit is not so clean. You can also achieve this by two different views for every table in the application schema. And on each of these views, create a private synonym for every user. For illustration purposes:
    Table name = Employee.
    Create a view employee_a on employee
    create a view employee_b on employee
    Let's say you have users x and y. X has access to employees of company a and y has access to employees of company b. You can now create private synonyms for each of these users as follows:
    create synonym employee on employee_a in x schema.
    create synonym employee on employee_b on y schema.
    This i have not tried but believe should work.
    Hope one of these options serve your purpose.

  • How to release row lock by using jdbc

    hi, currently we are using jdbc to create a connection and create a row lock , is there anyway to release the row lock? right now i am using resultset.close(), but this cause me problem since it release other resultset's row lock too. please help.

    hi, from your post, i understood that u know how to do row locking..
    How was it done ??
    I'm currently looking for answer to do row locking in Microsoft Access...
    These are the SQL stmt i've done without success..
    SELECT * FROM BSPerson WITH UPDLOCK WHERE ID = 'P001';
    SELECT * FROM BSPerson WHERE ID = 'P001' FOR UPDATE;
    Both stmt having error........
    Please help !
    A miliion thanks....

  • How to make row selection by checkbox in ADF table

    hello,
    using jdev11g TP4 , fusion web application
    when i drag my view object as ADF table into jsf page,
    i want to know how to make row selection by checkbox
    thanks
    greenApple
    Edited by: greenApple on Nov 10, 2008 11:33 AM

    Hi,
    the tree component has changed compared to 10.1.3. You no longer have a tableSelectmany component that renders as checkboxes. Instead you use the ctrl key and select the table rows
    Frank

  • How to merge rows with similar values in alv grid display in webdynpro

    Hi experts,
                   i want to know about how to merge rows with similar values in alv grid display of webdynpro.grouping rows is possible in table display in webdynpro but i am not able to do row grouping in the alv grid display in webdynpro.
    kindly suggest.
    thanks ,
    Anita.

    Hi Anita,
    did you find a solution for this? I have opened a Thread, if you know the answer maybe you could help me out:
    Is there an ALV function similar to the TABLE Row grouping?
    Thanx in advanced!!!
    Kind Regards,
    Gerardo J

  • How to repeat row header in all pages in Financial Reporting?

    Hi,
    I have created a simple Financial Report with landscape mode, I could not able to view the row header in second page. Please help me out , how to repeat row header in all pages?
    Edited by: Awesome on Dec 13, 2012 2:04 PM

    Hi,
    Refer following link which states how to change the Page Setup setting (just an addition to above poster's explanation):-
    http://docs.oracle.com/cd/E12825_01/epm.111/fr_user/frameset.htm?1900.html
    Regards,
    Edited by: 918547 on Dec 14, 2012 6:17 PM

  • How to convert rows into columns with decode function

    Hi,
    How to convert rows into columns with the help of decode function in oracle.
    thanks and regards
    P Prakash

    say
    col1 col2
    1 10
    2 20
    3 30
    then use
    select col1,
    sum(decode(col2,10,10)) "new1"
    sum(decode(col2,20,20))"new2"
    sum(decode(col2,30,30))"new3"
    from table_name
    group by col1;
    we used sum u can use ny function if wont u have to give the column name i.e col2 name also
    so i think u got it nw
    regards

  • How to Disable Row Detail in Sales Module

    Dear Experts,
    how to disable row detail option in sales module. how it is posible. we are using SAP Business One 2007. PL42
    Thanx

    AOA Rahil,
    I have just solved this problem, I was also facing the same one
    I am using B1DE, I have handled this on before menu click when open the form
    <B1Listener(BoEventTypes.et_MENU_CLICK, true)>  _
            Public Overridable Function OnBeforeMenuClick(ByVal pVal As MenuEvent) As Boolean
                'GENERATED CODE
                Me.LoadForm()
    1***            Dim Form As Form = B1Connections.theAppl.Forms.ActiveForm
       2 ***        Form.Settings.EnableRowFormat = False
                Return false
            End Function
    1--Capture the current form
    2--Disable Row Detail Form
    It worked for me
    Best Regards,
    Umer Nasim Mirza
    03004003633

  • How to see rows  errors not loaded by interface

    Hello, I have a simple interface, I am loading data within same oracle database from one schema to another schema.
    But I see 3 rows less.
    Can some body please advice how to see rows that are not loaded,what was reason etc.
    Thanks

    Hi,
    You can also see it within ODI by opening the Model --> right-clicking your target datastore -->Check --> Errors...
    It shows you the table E$_ table for this specific datastore. For each rejected row, you will see the whole set of columns plus the reason of the rejection.
    Hope it helps,
    Jerome Fr

  • How to add rows in tableview using javascipt

    Hi
    I had tableview and button in my page.If i click on the button one new row should be appended to the existing tableview.
    so , how to add rows in tableview using javascipt which are editable?
    Regards,
    Pydi.

    Hi,
      Javascript is client scripting language, which is mainly used for validations at the client side.
      To add new row using a HTMLB tag ucannot use javascript. Instead pass "visibleRowCount" variable to a abap variable and add the variable on every button click.. that wil increase the visible row count.
    Also the size of the table view is the size of the itnernal table, so append a blank like to the internal table or insert it at the top.
    If you are not using HTMLB tags and using simple HTML tags u can always add a row using java script.
    Regards
    Imran.

  • How to repeat rows in numbers on every page

    how to repeat rows in numbers on every page

    Hi mitesh hirani,
    Welcome to Apple Support Communities.
    Do you mean repeat Header Rows for tables?
    Menu > Print... > Print Setup (the panel on the right) > Repeat Table Headers
    Regards,
    Ian.

  • How to hide rows?

    Hello folks,
    I just would like to know that how to hide rows except dbms_rls package? I mean, it has been said that I can hide rows to create views but lets said that I have got 200 students and each student can see only their rows in students table, in that scenerio I have to create 200 views, isn't it? I just would like to learn that how to hide rows with using views? Do you have any ideas?
    Note: I know dbms_rls package, except this solution I am tryin to find onather solution.
    Thanks a lot.

    Hi,
    Polat wrote:
    Hello folks,
    I just would like to know that how to hide rows except dbms_rls package? I mean, it has been said that I can hide rows to create views but lets said that I have got 200 students and each student can see only their rows in students table, in that scenerio I have to create 200 views, isn't it? No! As you realized, that's not practical.
    If every student is a separate Oracle user, the USER fucntion will return the name of the current user. A view definition can reference that function, like this:
    CREATE OR REPLACE VIEW view_x
    AS
    SELECT   *
    FROM    table_x
    WHERE   student_account  = USER;If you logged in to Oracle as POLAT, then the view will contain only rows where student_account='POLAT'.
    If you logged in to Oracle as SYSTEM, then the view will contain only rows where student_account='SYSTEM'.
    If students do not have thier own Oracle accounts, then they are probably authenitcated by some procedure in your package. That procedure can set a SYS_CONTEXT variable, or write data to a global temporary table, which you can then use instead of the USER function in view definitions.
    Note: I know dbms_rls package, except this solution I am tryin to find onather solution.Why can't you use dbms_rls, or why don't you want to use it? It's a very powerful tool, and not vey hard to use.
    I'm not saying there's never a good reason not to use dbms_rls; I'm just asking if you have one.
    I hope this answers your question.
    If not, give a specific example of what you want. Post CREATE TABLE and INSERT statements for some sample data for all tables involved. Identify 2 or 3 different students, and show what the contents of the view should be for each student, given the same sample data. If students do not log in to Oracle with their own usernames, then explain how you know which student is currently logged in.

  • How to hide rows with merged cells?

    I would like to know how to hide rows on numbers with merged cells, could do it normally at excel but I am not being able to do it at Numbers.
    thanks!

    Felipe,
    To hide a row with Merged Cells, Un-Merge first, then Hide. Select the Merged Cells and Table > Unmerge.
    Note that this is only a problem with vertically merged cells when you want to Hide a Row.
    If you want to Hide a Column, you can't have a Horizontal Merge that involves that Column.
    Jerry

Maybe you are looking for

  • Call function in update task empty variables error

    Hello, I'm experiencing a weird error while using the addition "In update task". My Scenario is the following: Use the bapi_goodsmvt_create -> if there are no errors, fill some values and call my function and then commit everything. The problem is, w

  • Problem transporting Request from Development to Quality Assurance Server

    Hi All, I m facing a problem of Transporting requests from one System to other. When adjusting the Request ,the error message reads as follows : <b>RFC system error in system/destination [email protected]_HSE</b> Now,when I check the RFC Connection f

  • Can't upgrade 2012 standard to 2012 R2

    I have 2 production 2012 standard servers I need to upgrade to Server 2012 R2. When I try to complete an in-place upgrade I get an error that tells me an unexpected error occurred please restart the application. error 0x0. I've installed all updates

  • Help on testing of servlet using TCPMon

    I am trying to use TCPMon to test on my java servlet and when I press resend, the message below is generated. May I know how to solve it? Thanks you very much. HTTP/1.1 400 Bad Request Transfer-Encoding: chunked Date: Mon, 21 May 2007 01:21:44 GMT Se

  • Configurator for Photoshop CS4???? Where is 1.0?

    Hi, I have Photoshop CS4, and recently lost my custom panels because I restored my OS and lost a few applications. I would like to re-build a new panel for CS4, but I'm not sure how to do it anymore. I can't find a Configurator that is compatible to