Tree Level Query

Dear Sir
I need a Tree Level Query in looping Condition and examples using Sql Server
Regards
Mohamed Usman

in sql developer like this
select level, ename ,empno from emp
start with mgr = 1001
connect by prior empno=mgr;

Similar Messages

  • Can we hide filter in Search Master agreements standard top level query?

    Hi Experts, 
    I have a requirement to hide flter in standard Search Master Agreements top level query.  See below screen shot
    I have an idea how to delete filter in query but when i have added that query to top level navigation i don't have any idea.
    So i want to hide Business Unit & Region filter in Search Master Agreement query when it is in top level navigation.
    If anyone have idea please share with me how to hide.
    Thanks,
    Lava

    Hi Lava,
    It is not a filter but this a Standard field which is coming from the Master Agreement.
    So, you cannot hide or even delete any field.
    But if it is a custom field you can hide it by inactivating the respective field in Extension Defination.
    Please let me know if you need any assistance.
    Thanks,
    Raj.

  • How to count the tree levels?

    Hi..
    I'm a new memeber here.. and I have a problem :S
    My problem is about counting the maximum number of a tree levels.
    the question was: write a methode that receives a root of a binary tree and returns the maximum number of levels it has.
    I wrote the following methodes:
    public void depth() {
    System.out.print(depthHelper(root));
    private int depthHelper(TreeNode node) {
    int level = 1;
    if (node == null) {
    return 0;
    level = level + depthHelper(node.rightNode);
    return level;
    The problem is that these methodes count levels from one side which is the right side or left side if I wrote "node.leftNode".
    SO, how can I count them from both sides?
    I'll be very glad if you help me.

    It's often best to start with standard recursive tree traversal algoritm,
    private dH(TreeNode node) {
       if (node != null) {
          dH(node.leftNode);
          dH(node.rightNode);
    }You must keep track of the current depth and the maximum depth so far. The current depth is easy. You just increment it each time you go deeper.
    private dH(TreeNode node, int current) {
       if (node != null) {
          dH(node.leftNode, current + 1);
          dH(node.rightNode, current + 1);
    }The maximum depth is global to the tree so you should keep it outside the method. In each recursive step you compare it to the current depth
    int maximum = 0;
    private dH(TreeNode node, int current) {
       if (node != null) {
          if (current > maximum)
             maximum = current;
          dH(node.leftNode, current + 1);
          dH(node.rightNode, current + 1);
    }Now maximum contains the maximum depth.

  • Oracle Tree Hierarchy Query

    Hi,
    Hoping someone can assist with this query:
    I am currently using this query to construct a tree hierarchy, i.e.
    SELECT "EMP"."MGR" as "MGR",
            "EMP"."EMPNO" as "EMPNO",
            "EMP"."ENAME" as "ENAME" ,
            (select count(*)  from "EMP" "EMP2" where  "EMP2"."MGR" = "EMP"."EMPNO") BranchCount
    from
    "EMP" "EMP"
    where
    "EMP"."MGR"  =  :BRANCH_IDUsing this query, I also need to retrieve the LEVEL pseudo-column as well for each record retrieved as I need the LEVEL info for trying to determine at what level of the tree I am at.
    I would actually like to incorporate the LEVEL column into the above query - is this possible?
    Thanks.
    Tony.

    SQL> desc test
    Name Null? Type
    COLUMN1 VARCHAR2(10)
    COLUMN2 VARCHAR2(10)
    MGR VARCHAR2(10)
    SQL> select * from test
    2 /
    COLUMN1 COLUMN2 MGR
    1 a 33
    3 i 33
    2 g 33
    4 b 33
    5 c 44
    6 d 44
    22 e
    33 f 22
    44 h 22
    9 rows selected.
    SQL> select column1, column2, mgr, level
    2 from test
    3 start with mgr = '22'
    4 connect by prior column1 = mgr
    5 order by level
    6 /
    COLUMN1 COLUMN2 MGR LEVEL
    33 f 22 1
    44 h 22 1
    6 d 44 2
    4 b 33 2
    5 c 44 2
    3 i 33 2
    1 a 33 2
    2 g 33 2
    8 rows selected.

  • Hierarchical Tree Data Query/Record Group Question

    I need help with Hierarchical Forms right now. I'm currently trying to implement a hierarchical tree to display the different items in different categories. I have been reading up on it for the past few days, and i do not understand a few things.
    What is the difference between a data query and record group? they seem the same to me.
    How does the XX = prior XXX work? i understand that this is what connects the parent to the child.
    How do you determine what depth the node is? its done in the record group/data query, but how do i decide what level it is dynamically?
    Thanks a lot in advance!

    Thanks! I am unable to create a table specifically for the tree because i am using tables that have been ported live and are in use. My question about levels is how do I know which depth the node is. For example, i have a category called Information Technology and a category item called Business Informatics. I want to know how to decide that the Category(information technology) is on level 1 and the Item(business informatics) is on level 2.
    Information Technology
    |_
    Business Informatics
    And i do know how the Connect By XX = prior XXX works in the data query/record group.
    Thanks for your help!

  • Tree: execute query for ech node

    Hi,
    I use JDeveloper 10.1.3.1.0 and ADF.
    I use a af:tree object and when entire hierarchy exists of about 200 nodes, then this works fine.
    Now I have a hierarchy of 2000 nodes, first level 5 nodes, second level 4 nodes per nodes, third level 10 nodes per node
    and the fourth level about 10 nodes per node.
    When I enter the screen, I expand only the first level, but for each node (2000) the query has been executed.
    Is there a possibility to query only the first level nodes?
    Regards,
    LvL

    Hi,
    I use JDeveloper 10.1.3.1.0 and ADF.
    I use a af:tree object and when entire hierarchy exists of about 200 nodes, then this works fine.
    Now I have a hierarchy of 2000 nodes, first level 5 nodes, second level 4 nodes per nodes, third level 10 nodes per node
    and the fourth level about 10 nodes per node.
    When I enter the screen, I expand only the first level, but for each node (2000) the query has been executed.
    Is there a possibility to query only the first level nodes?
    Regards,
    LvL

  • Tree-Level Structural programming

    I have to do tree structural programming for the below query service_type in first level and then followed by item_number in second level and third level by component_id and fourth level by benefit_id. Let me know your thoughts
    for this programming structure. Any help here is appreciated.
    SELECT max(product_fee_version) max_product_fee_version,       p.description as product_description,       pf.cover_state,       i.service_type,       i.item_number,       i.description as item_desciption,       c.component_id,       c.description as component_description,       c.component_level,       bc.benefit_condition_id,       bc.from_date as benefit_effective_date,       bc.description as benefit_description,       bc.condition_period_length as waiting_period,       bc.single_amount,       bc.family_amount FROM item i INNER JOIN service_type st ON i.service_type=st.service_type AND st.claim_type='A' INNER JOIN component c ON i.item_number=c.item_number AND c.service_type IN (select service_type from service_type where claim_type='A')INNER JOIN benefit_condition bc ON bc.component_id=c.component_id AND bc.end_date IS NULL and bc.product_id IN (select product_id from product where product_type='A' and termination_date IS NULL)INNER JOIN product_fee pf ON pf.product_id=bc.product_id and pf.product_id IN (select product_id from product where product_type='A' and termination_date IS NULL) and pf.status_flag='A'INNER JOIN product p ON pf.product_id=p.product_id and p.product_id IN (select product_id from product where product_type='A' and termination_date IS NULL) and p.termination_date IS NULL GROUP BY        p.description,       pf.cover_state,       i.item_number,       i.service_type,       i.description,       c.component_id,       c.description,       c.component_level,       bc.benefit_condition_id,       bc.from_date,       bc.description,       bc.condition_period_length,       bc.single_amount,       bc.family_amount order by  p.description,       pf.cover_state,       i.item_number,       i.service_type,       i.description,       c.component_id,       c.component_level,       c.description,       bc.benefit_condition_id,       bc.from_date,       bc.description,       bc.condition_period_length,       bc.single_amount,       bc.family_amount
    -kccrga http://dbatrend.blogspot.com.au/

    Hello,
    instead of writing 3 times the same subquery I would suggest using a CTE where the logic is written once, then INNER JOIN the tables to this CTE instead of using the IN operator:
    WITH pp (product_id)
    AS (select product_id from product where product_type='A' and termination_date IS NULL)
    SELECT max(product_fee_version) max_product_fee_version, p.description as product_description, pf.cover_state, i.service_type, i.item_number
    , i.description as item_desciption, c.component_id, c.description as component_description, c.component_level,
    bc.benefit_condition_id, bc.from_date as benefit_effective_date, bc.description as benefit_description,
    bc.condition_period_length as waiting_period, bc.single_amount, bc.family_amount
    FROM item i
    INNER JOIN service_type st ON i.service_type=st.service_type AND st.claim_type='A'
    INNER JOIN component c ON i.item_number=c.item_number
    AND c.service_type IN (select service_type from service_type where claim_type='A')
    INNER JOIN benefit_condition bc ON bc.component_id=c.component_id AND bc.end_date IS NULL
    -- and bc.product_id IN (select product_id from product where product_type='A' and termination_date IS NULL)
    INNER JOIN pp ON bc.product_id = pp.product_id
    INNER JOIN product_fee pf ON pf.product_id=bc.product_id
    --and pf.product_id IN (select product_id from product where product_type='A' and termination_date IS NULL)
    and pf.status_flag='A'
    INNER JOIN pp ON pf.product_id = pp.product_id
    INNER JOIN product p ON pf.product_id=p.product_id
    --and p.product_id IN (select product_id from product where product_type='A' and termination_date IS NULL)
    INNER JOIN pp ON p.product_id = pp.product_id
    and p.termination_date IS NULL
    GROUP BY p.description, pf.cover_state, i.item_number, i.service_type, i.description
    , c.component_id, c.description, c.component_level, bc.benefit_condition_id, bc.from_date
    , bc.description, bc.condition_period_length, bc.single_amount, bc.family_amount
    order by p.description, pf.cover_state, i.item_number, i.service_type, i.description
    , c.component_id, c.component_level, c.description, bc.benefit_condition_id, bc.from_date
    , bc.description, bc.condition_period_length, bc.single_amount, bc.family_amount
    Some remarks:
    I would not use andpf.status_flag in the INNER JOIN, rather in a where statement before the group by.
    The Group by has slightly different ordering than the order by: c.component_level,       c.description, Is this on purpose?
    Jan D'Hondt - SQL server BI development

  • Carl's / Scott's Ajax Tree Example Query

    Hi,
    Hoping someone can assist, I have utilized Carl's and Scott's Ajax tree example, specifically have used the following example from Carl's app, i.e.:
    http://apex.oracle.com/pls/otn/f?p=11933:49:4073287192617448::NO:RP::
    All is working great but my query is, with the following query, that I am using, i.e.
    SELECT "EMP"."MGR" as "MGR",
            "EMP"."EMPNO" as "EMPNO",
            "EMP"."ENAME" as "ENAME" ,
            (select count(*)  from "EMP" "EMP2" where  "EMP2"."MGR" = "EMP"."EMPNO") BranchCount
    from
    "EMP" "EMP"
    where
    "EMP"."MGR"  =  :BRANCH_IDI need to also retrieve the LEVEL pseudo-column as well for each record retrieved as I need the LEVEL info for trying to determine at what level of the tree I am at.
    I believe you can only use the LEVEL column with a CONNECT BY PRIOR clause.
    I would actually like to incorporate the LEVEL column into the above query - is this possible?
    If not, can someone pls assist with re-writing the above query using a connect by clause which will still retrieve the same info as Carl's original query.
    Thanks.
    Tony.

    Hello,
    Sure just replace the body section of the procedure with something like this.
    for c1 in (
    select emp_no,emp_name,emp_manager
    from emps
    order by 2 asc;
         )loop
    htp.prn ('<div>' || c1.emp_no || '-' || c1.emp_name || '-' || c1.emp_manager||'</div>');
    end loop;
    Carl

  • Tree Level - Link

    Hello Everyone,
    I have a tree with different levels,
    How do you create a link for each level such that when level 1 or level 2 is clicked, it goes to page1 or page 2
    and passes the respective Process_ID  to that page.
    Thank You for your time, Appreciate your Help
    Sam
    Apex 3.2
    Table Name: Process
    Process_ID
    Parent_ID
    Process_NM
    Level_NO
    Process_ID        Parent_ID        Process_NM         Level_NO
    1                      0        test                     0
    2                    1        Etest                1
    3                    2        Rtest              2
    4                    3        Atest              3
    5                    3        Dtest              3
    6                    7        Qtest              4
    7                    5        Wtest             5
    8                    7        Stest              7Under Tree these are the settings:
    Tree Type: Dynamic - From SQL Query
    Tree Query:
    select "PROCESS_ID" id,
    "PARENT_ID" pid,
    "PROCESS_NM" name,
    "PROCESS_NM" link,
    null a1,
    null a2
    from PROCESS
    order by parent_id
    Link Templates:
    Name Link Anchor Tag
    href="#LINK#">#NAME# (with the tags <a....)
    Name Link Not Anchor Tag
    #NAME#
    Thanks
    Sam

    Oops - forgot about the second part of your question - passing process ID to the page:
    select "PROCESS_ID" id,
    "PARENT_ID" pid,
    "PROCESS_NM" name,
    case when level_no = 1 then 'f?p=&APP_ID.:1:&SESSION.::::P1_PROCESS_ID:' || process_id
         when level_no = 2 then 'f?p=&APP_ID.:2:&SESSION.::::P2_PROCESS_ID:' || process_id end link,
    null a1,
    null a2
    from PROCESS
    order by parent_idHope this helps,
    John

  • Complex Tree Structure Query

    Hi,
    I have a table which contains the hierarchial data upto 4 levels. I needed to have the information of all the four levels in a row, so I created 3 tree structured views and one another view using the tree structured views as below
    --To get the great grand parent id for the children*
    CREATE OR REPLACE VIEW VR_PO_TREE AS
    SELECT LEVEL pathlength,
    connect_by_root partner_organization_id root_po,
    partner_organization_id,
    partner_common_name,
    partner_organization_type
    FROM partner_organization po
    START WITH po.org_entity_above_id IS NULL
    CONNECT BY PRIOR po.partner_organization_id = po.org_entity_above_id
    ORDER BY po.partner_organization_id;
    -- level 2 (grant parent) id
    CREATE OR REPLACE VIEW VR_PO_AREA_TR AS
    SELECT LEVEL pathlength,
    connect_by_root partner_organization_id root_po,
    partner_organization_id,
    partner_common_name,
    partner_organization_type
    FROM partner_organization vcpo
    START WITH vco.partner_organization_type = 'AREA'
    CONNECT BY PRIOR vcpo.partner_organization_id = vcpo.org_entity_above_id
    ORDER BY vcpo.partner_organization_id;
    --level 3 (parent) id*
    CREATE OR REPLACE VIEW VR_PO_REGION_TREE AS
    SELECT LEVEL pathlength,
    connect_by_root partner_organization_id root_po,
    vcpo.partner_organization_id,
    vcpo.partner_common_name,
    vcpo.partner_type
    FROM partner_organization vcpo
    START WITH vcpo.partner_organization_type = 'REGION'
    CONNECT BY PRIOR vcpo.partner_organization_id = vcpo.org_entity_above_id
    ORDER BY vcpo.partner_organization_id;
    ---and finally created a view to have all the levels in a single row
    CREATE OR REPLACE VIEW VR_PO_ALL_TREE AS
    SELECT pot.pathlength,
    po.partner_organization_id,
    po.partner_common_name,
    pot.root_po int_partner_org_id,
    pot.intl_po_name int_partner_common_name,
    vpat.root_po area_partner_org_id,
    vpat.area_po_name area_partner_common_name,
    vprt.root_po region_partner_org_id,
    vprt.region_po_name region_partner_common_name
    FROM partner_organization po
    JOIN vr_po_tree pot
    ON pot.partner_organization_id = po.partner_organization_id
    LEFT outer JOIN vr_po_area_tr vpat
    ON vpat.partner_organization_id = po.partner_organization_id
    LEFT OUTER JOIN vr_po_region_tree vprt
    ON vprt.partner_organization_id = po.partner_organization_id;
    All the views are working fine, very fast, giving the expected output.
    if we make a join to the view vr_po_all_tree in a query that also works fine. However, if we make an outer join to a query that has the join to vr_po_all_tree, Oracle throws an internal error - Ora-00600 internal error codes, arguments [qrctce1], [0],[0],.....
    Is the view vr_po_all_tree is cause for this problem?, in such a case can any one help me to rewrite the view with a simple query to give the same results?
    Thanks in advance.
    Nattu
    Edited by: Nattu on Nov 26, 2009 8:25 PM
    Edited by: Nattu on Nov 27, 2009 11:48 AM
    Edited by: Nattu on Nov 27, 2009 11:55 AM

    Hi,
    if we make a join to the view vr_po_all_tree in a query that also works fine. However, if we make an outer join to a query that has the join to vr_po_all_tree, Oracle throws an internal error - Ora-00600 internal error codes, arguments [qrctce1], [0],[0],.....
    Is the view vr_po_all_tree is cause for this problem?As Sven said, ORA-00600 is the sign of some low-level problem, and you should seek a solution from Oracle support. Your views are not the cause of this problem; most likely, the views trigger something that would not be a problem except for a installatin problem or maybe a bug.
    We can try to find a work-around for you, but don't ignore the problem.
    in such a case can any one help me to rewrite the view with a simple query to give the same results?It seems very likely that you could do something that didn't involve so many CONNECT BYs and outer joins.
    Post some sample data (CREATE TABLE and INSERT statements) and the results you want from that data.
    Simplify as much as possible. For example, in the first view you say:
    CREATE OR REPLACE VIEW VR_PO_TREE AS
    SELECT LEVEL pathlength,
    connect_by_root partner_organization_id root_po,
    connect_by_root partner_common_name intl_po_name,
    connect_by_root is_wbti is_wbti,
    connect_by_root is_sil_int is_sil_int,
    connect_by_root organization_entity_code int_org_entity_code,
    org_entity_above_id, partner_organization_id,
    partner_organization_type,
    sys_connect_by_path(partner_organization_id, '\') po_path_id,
    sys_connect_by_path(partner_common_name, '\') po_path_name
    FROM ...That is, you're selecting 1 pseudo-column (LEVEL), 4 CONNECT_BY_ROOTs, 3 plain columns, and 2 SYS_CONNECT_BY_PATHs.
    Can you post a problem with just one of each: 1 pseudo-column, 1 CONNECT_BY_ROOT, 1 plain column, and 1 SYS_CONNECT_BY_PATH?  Adding the others later should be easy.
    Any information you can give about the data would be helpful.
    In particular,
    (a) Can org_entity_above be NULL on the same row where partner_organization_type is 'AREA' or 'REGION'?
    (b) How many ancestors with partner_organization_type = 'AREA' Can a node have? 1? No more than 1?  1 or more? 0 or more?
    (c) Same for 'REGION'.  How many ancestors with partner_organization_type = 'REGION' Can a node have? 1? No more than 1?  1 or more? 0 or more?
    (d) Can a node with partner_organization_type = 'REGION' be the ancestor of a row with partner_organization_type = 'AREA'?
    (e) Other way around: can a node with partner_organization_type = 'AREA' be the ancestor of a row with partner_organization_type = 'REGION'?
    Some of these questions may seem silly to you, because you know the table and the data so well.  I don't, so you'll have to explain things.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

  • Connect by level query is taking too long time to run

    Hello,
    I have a query that returns quarters (YYYYQ) of a begin- and enddate within a specific id, that is built with a connect by level clause, but the query is running to long. I have used explain plan to see what the query is doing, but no silly things to see, just a full table scan, with low costs.
    This is the query:
    select to_char(add_months( cpj.crpj_start_date,3*(level - 1)),'YYYYQ') as sales_quarter
    , cpj.crpj_id as crpj_id
    from mv_gen_cra_projects cpj
    where cpj.crpj_start_date >= to_date('01/01/2009','mm/dd/yyyy')
    and cpj.crpj_start_date <= cpj.crpj_end_date
    and cpj.crpj_routing_type = 'A'
    and ( cpj.crpj_multi_artist_ind = 'N'
    or cpj.crpj_multi_artist_ind is null)
    connect by level <= 1 + ceil(months_between(cpj.crpj_end_date,cpj.crpj_start_date)/3);
    The result have to be like this:
    SALES_QUARTER CRPJ_ID
    20091 100
    20092 100
    20093 100
    20094 100
    20101 100
    20102 100
    Can anyone help me out with this?

    but no silly things to see, just a full table scan, with low costs.Well, maybe an index scan would be faster?
    However:
    You will need to provide us some more details, like:
    - database version (the result of: SQL> select * from v$version;)
    - post the explain plan output (put the tag before and after it, so indentation and formatting are maintained, see the [FAQ|http://forums.oracle.com/forums/help.jspa] for more explanation regarding tags )
    - what are your optimizer settings (the result of: SQL> show parameter optimizer)
    - if applicable: are your table statistics up to date?
    - mv_gen_cra_projects  is a materialized view perhaps?
    Edited by: hoek on Jan 26, 2010 10:50 AM                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

  • Create a New Tree in Query Access Manager

    Folks,
    Hello. In PeopleTools Query Access Manager, click on button "Create a New Tree" to create a new Query Access Tree, the system always comes up this message:
    "You are not authorized to update definition QUERY_TREE_OLAP. You are not authorized to update the specific definition. Contact your security administrator for access to the specified definition."
    Do any folks understand how to solve this problem ?
    Thanks.

    I figured it was that simple.
    I haven't seen you on here in awhile.

  • Tree Attributes Query Example is Incorrect

    I have been trying to create a Tree region in Application Express 4.0.2.00.07.
    In the "Tree Attributes" page the exmaple and help text are contradicting, the example is oncorrect whereas the help text is correct.
    This is very frustrating!
    See text:
    Syntax: select status, level, name, icon, id, tooltip, link from ... where ... start with... connect by prior id = pid order siblings by ...
    +1. You must select the columns in the following order (e.g. status, level, name, icon, id, tooltip, link..)+
    +2. Ordering applies the order_by_clause to the siblings of the hierarchy+
    Example:
    select case when connect_by_isleaf = 1 then 0 when level = 1 then 1 else -1 end as status,
    ENAME as title
    NULL  as icon,
    EMPNO as value,
    ENAME as tooltip,
    NULL  as link
    from EMP
    start with MGR is null
    connect by prior EMPNO = MGR
    order siblings by ENAME
    When following the example, I kept getting a javascript error when running the page and when viewing the source it was the ORA error No Data Found.
    Once I noticed the contradiction between point 1 of the Syntax help and the code example I tried using the columns in the Syntax help and the tree started working.
    Given the proximity of these two pieces of boilerplate text it'd be great if it could be made consistent.
    Hopefully this post will help anyone else who encounters this problem.

    And should look into this proper documentation http://docs.oracle.com/cd/E17556_01/doc/user.40/e15517/app_comp.htm#BABBCAEJ

  • Purchase Register - Header level query issue

    Hi Guru's,
    I tried the following query for Purchase Register (Header Level) but I am not able to get the following details -                              1) AP Invoices which are without PO
    2) Freight amount not getting reflected
    SELECT T0.DocNum as 'PO. No.',
    T0.DocDate as 'PO. Date',
    M.DocNum as 'A/P Invoice No.',
    M.DocDate as 'Inv. Date',
    M.CardName as 'Vendor Name',
    M.NumAtCard as 'Bill No. & Date',
    (Select Sum(LineTotal) FROM PCH1 L Where L.DocEntry=M.DocEntry) as 'Base Amt.(Rs.)',
    (SELECT Sum(TaxSum) FROM PCH4 where statype=-90 and DocEntry=M.DocEntry) as 'ED (Rs.)',
    (SELECT Sum(TaxSum) FROM PCH4 where statype=-60 and DocEntry=M.DocEntry) as 'EDCS (Rs.)',
    (SELECT Sum(TaxSum) FROM PCH4 where statype=8 and DocEntry=M.DocEntry) as 'HECS (Rs.)',
    (SELECT Sum(TaxSum) FROM PCH4 where statype=1 and DocEntry=M.DocEntry) as ' VAT (Rs.) ',
    (SELECT Sum(TaxSum) FROM PCH4 where statype=4 and DocEntry=M.DocEntry) as ' CST (Rs.) ',
    (SELECT Sum(TaxSum) FROM PCH4 where statype=-80 and DocEntry=M.DocEntry) as ' CVD (Rs.) ',
    (SELECT Sum(TaxSum) FROM PCH4 where statype=5 and DocEntry=M.DocEntry) as ' Ser.Tax (Rs.) ',
    (SELECT Sum(TaxSum) FROM PCH4 where statype=6 and DocEntry=M.DocEntry) as 'CS on Ser.Tax (Rs.)',
    (SELECT Sum(TaxSum) FROM PCH4 where statype=7 and DocEntry=M.DocEntry) as 'HECS_ST (Rs.)',
    (Select Sum(LineTotal) From PCH3 Q Where Q.DocEntry=M.DocEntry) AS 'Freight (Rs.)',
    M.WTSum AS 'TDS (Rs.)',
    M.DocTotal as 'Total (Rs.)'
    FROM OPOR T0 INNER JOIN POR1 T1 ON T0.DocEntry = T1.DocEntry
    INNER JOIN OPDN T2 ON T2.DocEntry = T1.TrgetEntry
    INNER JOIN PDN1 T3 on T3.DocEntry = T2.Docentry
    INNER JOIN OPCH M ON M.DocEntry = T3.TrgetEntry
    LEFT OUTER JOIN PCH1 L on L.DocEntry=M.DocEntry
    LEFT OUTER JOIN PCH4 T on T.DocEntry=L.DocEntry and L.LineNum=T.LineNum
    LEFT OUTER JOIN PCH5 J ON M.DocEntry = J.AbsEntry
    LEFT OUTER JOIN PCH3 Q ON M.DocEntry = Q.DocEntry
    WHERE M.DocDate >= '[%0]' AND M.DocDate <= '[%1]'
    GROUP BY
    T0.DocNum,T0.DocDate,M.DocNum,M.DocDate,M.CardName,M.NumAtCard,M.DocEntry,M.[DiscSum],M.WTSum,M.DocTotal
    ORDER BY
    T0.DocNum,T0.DocDate,M.DocNum,M.DocDate,M.CardName,M.NumAtCard,M.DocEntry,M.[DiscSum],M.WTSum,M.DocTotal
    Regards,
    Abhishek

    Hi Abhishek,
    Try this Query Report, you will be get the exact result in  this Query.
    your requirement.
    1. A/P Invoice with Purchase Order.
    2. The Freight amount will display the Freight Column in the query.
    Try this below Query,
    SELECT T0.DocNum as 'PO. No.',
    T0.DocDate as 'PO. Date',
    M.DocNum as 'A/P Invoice No.',
    M.DocDate as 'Inv. Date',
    M.CardName as 'Vendor Name',
    M.NumAtCard as 'Bill No. & Date',
    (Select Sum(LineTotal) FROM PCH1 L Where L.DocEntry=M.DocEntry) as 'Base Amt.(Rs.)',
    (SELECT Sum(TaxSum) FROM PCH4 where statype=-90 and DocEntry=M.DocEntry) as 'ED (Rs.)',
    (SELECT Sum(TaxSum) FROM PCH4 where statype=-60 and DocEntry=M.DocEntry) as 'EDCS (Rs.)',
    (SELECT Sum(TaxSum) FROM PCH4 where statype=7 and DocEntry=M.DocEntry) as 'HECS (Rs.)',
    (SELECT Sum(TaxSum) FROM PCH4 where statype=1 and DocEntry=M.DocEntry) as ' VAT (Rs.) ',
    (SELECT Sum(TaxSum) FROM PCH4 where statype=4 and DocEntry=M.DocEntry) as ' CST (Rs.) ',
    (SELECT Sum(TaxSum) FROM PCH4 where statype=10 and DocEntry=M.DocEntry) as ' CVD (Rs.) ',
    (SELECT Sum(TaxSum) FROM PCH4 where statype=5 and DocEntry=M.DocEntry) as ' Ser.Tax (Rs.) ',
    (SELECT Sum(TaxSum) FROM PCH4 where statype=6 and DocEntry=M.DocEntry) as 'CS on Ser.Tax (Rs.)',
    (SELECT Sum(TaxSum) FROM PCH4 where statype=8 and DocEntry=M.DocEntry) as 'HECS_ST (Rs.)',
    (Select Sum(LineTotal) From PCH3 Q Where Q.DocEntry=M.DocEntry) AS 'Freight (Rs.)',
    M.WTSum AS 'TDS (Rs.)',
    M.DocTotal as 'Total (Rs.)'
    FROM OPOR T0 INNER JOIN POR1 T1 ON T0.DocEntry = T1.DocEntry
    INNER JOIN OPDN T2 ON T2.DocEntry = T1.TrgetEntry
    INNER JOIN PDN1 T3 on T3.DocEntry = T2.Docentry
    INNER JOIN OPCH M ON M.DocEntry = T3.TrgetEntry
    LEFT OUTER JOIN PCH1 L on L.DocEntry=M.DocEntry
    LEFT OUTER JOIN PCH4 T on T.DocEntry=L.DocEntry and L.LineNum=T.LineNum
    LEFT OUTER JOIN PCH5 J ON M.DocEntry = J.AbsEntry
    LEFT OUTER JOIN PCH3 Q ON M.DocEntry = Q.DocEntry
    WHERE M.DocDate >= '[%0]' AND M.DocDate <= '[%1]'
    GROUP BY
    T0.DocNum,T0.DocDate,M.DocNum,M.DocDate,M.CardName,M.NumAtCard,M.DocEntry,M.[DiscSum],M.WTSum,M.DocTotal
    ORDER BY
    T0.DocNum,T0.DocDate,M.DocNum,M.DocDate,M.CardName,M.NumAtCard,M.DocEntry,M.[DiscSum],M.WTSum,M.DocTotal
    Regards,
    Madhan.

  • Aggregation level query "value help" = Only Values in InfoProv doesn't work

    Hi,
    I have a problem with Selection Variable for a BEx Query :
    - I'm working with SAP BI 7.0 support package 15
    - My query is an input ready query built for an "aggregation level" based on "real time infocube" (Planning);
    - Characteristic, I want to filter with variable, has query property Advanced->Query Execution for Filter Value Selection = Only Values in InfoProvider
    - Characteristic (info-object) has set the property: Business Explorer tab--> Query Def. Filter Value Selection as Only Values in the info-provider...
    My problem is:
    when I execute a query,
    the Select Values for Variables screen appears
    I push on the Select from List button
    and Select Values For MyCharacteristic appears...
    but it shows me all values in master data table of my characteristic instead of only values in the infoprovider!!!
    If I build a query for the Real Time Cube it works correctly, but if the query is built for the aggregation level it doesn't work!
    Could someone explain me why it doesn't work correctly?
    Thanks in advanced
    Fede

    Thanks to  Mariana Lazar
    30.03.2009 - 12:30:36 CET - Risposta by SAP     
    Dear Fede,
    Regarding the query built on aggregation level please note the following
    the aggregation level is always a Virtual Provider built other
    InfoProvider and hence it does not have the dimension table and hence
    the F4 mode D is not supported.
    Therefore when aggregation level is used in a query, F4 does not supportD-mode: 'Only Values in InfoProvider' and all master data values are
    displayed in the value list.
    Reference from the note
    984229 F4 modes for input help as of SAP NetWeaver 2004s BI
    4. Since other InfoProviders do not have a dimension table, the system
    displays only posted values if you select "Only Posted Values for
    Navigation". Otherwise, it displays the values from the master data
    table.
    Hope this should clarify your doubts. Please let me know if you have
    questions else please confirm the message at your earliest convenience.
    Thank you for your cooperation and kind regards,
    @KR@ Mariana Lazar
    Senior Support Consultant
    SAP Active Global Support
    Netweaver Business Warehouse

Maybe you are looking for

  • Metadata identifying a person in a photo

    In the olden days, family photos went in a shoe box, and if you were lucky, someone wrote on the back of it to tell you who was in the photo. If nobody did that, chances are that a priceless old family photo would eventually become a worthless photo

  • Dreaded Apple logo and spinning circle.

    I have the 20 inch I mac and I am running leopard. Last night although my mac is on a power bar we did have a few power surges. Now this morning all i get is the logo and spinning circle I have checked the ram it all seems good tried it without no lu

  • FB02- update XREF3 fields for G/L account also

    Hi all,    My requirement is to update the XREF3-> fields using transaction FB02 for the all accounts (Customer, G/L , Vendor) I have used Function module FI_DOCUMENT CHANGE whcih is updating the XREF -> fields for only Customer account.I want update

  • Photoshop elements, Programm crash while the face recognition

    I installes an update from PS elements 8.0 to 12.0. After I have converted the catalog, I startet PS elements 12. I saw my pictures for a second. Then the screen "Face recognition" occured. Then the Programm ist closed with an error. Can I deactivate

  • Manufacturer Part number MFRPN

    Manufacturer Part Number (MFRPN) is not available for mapping in BAPI_PO_CREATE1 whereas it is  available in BAPI_PO_CREATE. If you have selected item from material master in SRM and you are using BAPI_PO_CREATE1, in R/3 it reads the MFRPN from mater