Help build a query !!!

There are two tables. One consists of members with expenses and next with fixed percentile. I need to build a single query based upon following
1. Need to know the number of members that fall under a fixed range of percent like 10%, 40%, 50%. Suppose, total no of members = 50 then
10% -> 5
40% -> 20
50% -> 25
2. Now I need to rank the members as per their expenses. So, if following be the expenses of the members sorted by expenses
A1 100
A2 99
A3 98
A4 97
A5 96
A6 95
A50 50
then
total expense should be found out as
10% [sum of top 5 : From A1 to A5] = 100 + 99 + 98 + 97 + 96 = 490
40% [sum of next 20: From A6 to A26]
50% [sum of next 25: From A27 to A50]
Please help !!!!!
Edited by: josleen on Jan 11, 2010 7:50 AM

Hi,
There are a number of analytic functions for dealing with percentiles.
Depending on how you want to handle ties, how you count duplicate values, and other factors, PERCENT_RANK might be best for this problem.
You really should post the information Centinul requested whenever you have a question.
If you can phrase your question in terms of commonly available tables, then you don't have to post them.
For example, to group employees from the scott.emp table according to their salaries, and get a total of salaries by group, you could create a groups table and join it to the emp table, like this:
CREATE TABLE     groups
(      seq_id     NUMBER
,      label     VARCHAR2 (20)
,      low_pct     NUMBER      -- lowest number IN this group
,      high_pct     NUMBER      -- lowest number NOT IN this group, but in the next highest group
INSERT INTO groups (seq_id, label, low_pct, high_pct) VALUES (1, 'Top 10%',     0,     10);
INSERT INTO groups (seq_id, label, low_pct, high_pct) VALUES (2, '10%-50%',     10,     50);
INSERT INTO groups (seq_id, label, low_pct, high_pct) VALUES (3, 'Bottom 50%',     50,     101);
COMMIT;
WITH     got_pct          AS
     SELECT ename
     ,      sal
     ,      100 * PERCENT_RANK () OVER ( ORDER BY sal DESC
                                              ,          empno
                           )     AS pct
     FROM   scott.emp
SELECT    g.label
,       SUM (p.sal)     AS group_total
FROM       got_pct     p
JOIN       groups     g     ON     p.pct     >= g.low_pct
                      AND     p.pct     <  g.high_pct
GROUP BY  g.label
ORDER BY  MIN (g.seq_id)
;Output:
LABEL                GROUP_TOTAL
Top 10%                     8000
10%-50%                    12875
Bottom 50%                  8150If you need help understanding a query with sub-queries, it helps to run the sub-query by iteself.
In this case:
WITH     got_pct          AS
     SELECT ename
     ,      sal
     ,      100 * PERCENT_RANK () OVER ( ORDER BY sal DESC
                                              ,          empno
                           )     AS pct
     FROM   scott.emp
SELECT     *
FROM     got_pct
;produces this output:
ENAME             SAL        PCT
KING             5000          0
SCOTT            3000 7.69230769
FORD             3000 15.3846154
JONES            2975 23.0769231
BLAKE            2850 30.7692308
CLARK            2450 38.4615385
ALLEN            1600 46.1538462
TURNER           1500 53.8461538
MILLER           1300 61.5384615
WARD             1250 69.2307692
MARTIN           1250 76.9230769
ADAMS            1100 84.6153846
JAMES             950 92.3076923
SMITH             800        100In case of a tie, PERCENT_RANK assigns the same result to all rows with the same input value. The reason I included empno in the analytic ORDER BY clause was to prevent ties. Otherwise, both SCOTT and FORD (with the exact same sal=3000) would be assigned pct=7.69230769, and the "Top 10%" would then include 3 out of 14 rows (over 21% of the rows), which, outside of Lake Woebegone, shouldn't happen.
Edited by: Frank Kulash on Jan 11, 2010 11:02 AM
Explanation added.

Similar Messages

  • Need help in building search query

    Guys ..
    Problem Description:
    I have a huge table that is indexed using CONTEXT.
    I want to write a search query that considers the following:
    1. number of keywords match
    2. takes care of spelling mistakes, synonyms and acronyms
    3. proximity - the keywords should not be too far of each other.
    e.g. I have this phrase: "Horizontal Stabilizer Trim Brake"
    I was thinking of writing a query like:
    SELECT SCORE(1) SCORE,
    TEXT text
    FROM MY_TABLE
    WHERE CONTAINS(TEXT, '(Horz | Horizontal) ACCUM (Stab | Stabilier) ACCUM Trim ACCUM (Brk | Break)', 1) >= 0
    ORDER BY SCORE DESC
    The results doesnt look satisfactory. I have not used "near" operator as i dont know how to use it.
    Please help me as I am very much new to Oracle Text.
    -G

    Well, I'm not going to write the function for you, but we can at least talk through a general strategy.
    A lot depends on how you help your users on the front end -- for example, if they're searching a technical document, you may want to return results that aren't perfect matches but you do want to make sure the user picks 'mandatory' and 'useful' keywords in a way that lets you figure out which ones are really important. On the other hand, if you're google and have to handle queries like 'horizontal stabilizer trim brake' and 'were Pete and Jenny in the break room' then you run the risk of spending too much time looking for interesting words, almost doing a full-text search on the query trying to derive meaning.
    So I'm going to presume that you have some control over what/how the users generate their searches so that finding keywords isn't the issue.
    The plan will be to parse the query a bit to find the interesting words, clean them up, and weigh their importance, then use transformed data to build the query template to score various combinations.
    So here's some pseudocode for the function:
    function parse_query(pQueryWords in clob) returns clob as
    begin
        generate_token_list (); -- split the query into a set of individual tokens/words
        for each token in token_list
            if it's a mandatory word then accumtokenlist := accumtokenlist || ' ' || token ||'*10' -- weigh the presence of the token strongly
            if it's a useful word then accumtokenlist := accumtokenlist || ' ' || token ||'*5' -- domain-specific words are also important
            if it's a stopword or reserved word, then do not add it to the list
            if it's not on my lists, then accumtokenlist := accumtokenlist || ' ' || token
                                         and normaltokenlist := normaltokenlist ||' ' || token
        end;
        --so now, we have two lists, one for NEAR and one for ACCUM
        now build the guts of the template
            querytemplate := querytemplate || '<seq> || normaltokenlist || '</seq>';
            querytemplate := querytemplate || '<seq> || replace (accumtokenlist, ' ',' ACCUM ') || '</seq>';
            querytemplate := querytemplate || '<seq>$' || replace(normaltokenlist,' ','$') || '</seq>';
            querytemplate := querytemplate || '<seq>? || replace(replace(accumtokenlist,' ',' ?'),' ', ' accum ') || </seq>';  -- first fuzzy the words, then accum
            querytemplate := querytemplate || '<seq>? || replace(replace(normaltokenlist,' ',' ?'),' ', ' near ') || </seq>';  -- first fuzzy the words, then near
        return querytemplate
    end;So, with a 'cooked' query text that is template-friendly, all we need to do is apply a template that is aware of your inputs:
    query_Template_string := '
    <query>
       <textquery lang="ENGLISH" grammar="CONTEXT"> horizontal stabilizer*5 trim brake*10
         <progression> '
    || parse_query('horizontal stabilizer trim brake')  ||
    '     </progression>
       </textquery>
      <score datatype="INTEGER" algorithm="COUNT"/>'
    </query>So that's an example of one approach.

  • Please can someone help me to build a query

    Please can someone help me to build a query for getting the following results. I work with Oracle 9.
    My data is about this:
    Projectid / Activitycode / Act.DS / Earlystart / ActualStart
    {color:#ff0000}P001 / 110M / blabla / 1-1-08 / 1-1-08{color}
    {color:#3366ff}P001 / 230M / fdsfds / 31-1-09 / null{color}
    P001 / 450M / fsfsd / 1-4-09 / null
    P002 / null / null / 1-12-08 / 1-12-08
    {color:#3366ff}P002 / 110M / nhggh / 5-2-09 / null{color}
    P002 / 750M / wdwdwd / 5-2-09 / null
    P002 / 210M / plplplp / 31-12-08 / 31-12-08
    {color:#ff0000}P002 / 550M / ewdwd / 5-1-09 / null{color}
    I'd like to get one row for each Projectid with the {color:#3366ff}first next Early- or Actualstart{color} {color:#3366ff}after today{color} and one row with the {color:#ff0000}latest early-/actualstart before today{color}. When there are two or more rows with the same date then I want the first (minimum) Activitycode. This last condition makes it insoluble for me!
    I've tryed SQL with nested Select-statements in the Where-clause. But I've got still 2 rows per projectid because I select the min(nvl(Earlystart ,ActualStart ) I've tryed SQL with an Select in the FROM-claus with Partion BY, but I can't get it work right.
    Can someone show me the right way to solve my problem?

    How's this?
    with my_tab as (select 'P001' projectid,
                           '110M' activitycode,
                           'blabla' act_ds,
                           to_date('01/01/2008', 'dd/mm/yyyy') earlystart,
                           to_date('01/01/2008', 'dd/mm/yyyy') actualstart
                    from   dual
                    union all
                    select 'P001' projectid,
                           '230M' activitycode,
                           'fdsfds' act_ds,
                           to_date('31/01/2009', 'dd/mm/yyyy') earlystart,
                           null actualstart
                    from   dual
                    union all
                    select 'P001' projectid,
                           '450M' activitycode,
                           'fsfsd' act_ds,
                           to_date('01/04/2009', 'dd/mm/yyyy') earlystart,
                           null actualstart
                    from   dual
                    union all
                    select 'P002' projectid,
                           null activitycode,
                           null act_ds,
                           to_date('01/12/2008', 'dd/mm/yyyy') earlystart,
                           to_date('01/12/2008', 'dd/mm/yyyy') actualstart
                    from   dual
                    union all
                    select 'P002' projectid,
                           '110M' activitycode,
                           'nhggh' act_ds,
                           to_date('05/02/2009', 'dd/mm/yyyy') earlystart,
                           null actualstart
                    from   dual
                    union all
                    select 'P002' projectid,
                           '750M' activitycode,
                           'wdwdwd' act_ds,
                           to_date('05/02/2009', 'dd/mm/yyyy') earlystart,
                           null actualstart
                    from   dual
                    union all
                    select 'P002' projectid,
                           '210M' activitycode,
                           'plplplp' act_ds,
                           to_date('31/12/2008', 'dd/mm/yyyy') earlystart,
                           to_date('31/12/2008', 'dd/mm/yyyy') actualstart
                    from   dual
                    union all
                    select 'P002' projectid,
                           '550M' activitycode,
                           'ewdwd' act_ds,
                           to_date('05/01/2009', 'dd/mm/yyyy') earlystart,
                           null actualstart
                    from   dual)
    -- above mimics your table; main query is below:
    select mt2.projectid,
           mt2.activitycode,
           mt2.act_ds,
           mt2.earlystart,
           mt2.actualstart
    from   (select mt.projectid,
                   mt.activitycode,
                   mt.act_ds,
                   mt.earlystart,
                   mt.actualstart,
                   mt.date_col,
                   mt.before_after_today,
                   row_number() over (partition by mt.projectid, mt.before_after_today
                                      order by mt.date_col asc) rn_after,
                   row_number() over (partition by mt.projectid, mt.before_after_today
                                      order by mt.date_col desc) rn_before
            from   (select projectid,
                           activitycode,
                           act_ds,
                           earlystart,
                           actualstart,
                           coalesce(actualstart, earlystart, to_date('01/01/4000', 'dd/mm/yyyy')) date_col,
                           case when coalesce(actualstart,
                                              earlystart,
                                              to_date('01/01/4000', 'dd/mm/yyyy')) <= trunc(sysdate) then 1
                                else 2
                           end before_after_today
                    from   my_tab) mt) mt2,
            (select 1 id, 1 col_id from dual union all
             select 1 id, 2 col_id from dual) dummy
    where  dummy.id = case when mt2.before_after_today = 1 then rn_before
                           else rn_after
                      end
    and    mt2.before_after_today = dummy.col_id
    PROJECTID     ACTIVITYCODE     ACT_DS     EARLYSTART     ACTUALSTART
    P001     110M     blabla     01/01/2008     01/01/2008
    P001     230M     fdsfds     31/01/2009     
    P002     550M     ewdwd     05/01/2009     
    P002     110M     nhggh     05/02/2009     

  • Help in Pivot query

    Hi All,
    For below given data, I want query result shows all months in the outpt, even if there is no data for that month.
    If there is no data for a month it should display 0 as the amount.
    Please help me in building this query.
    version : Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - 64bi
    create table ledger
    (id number, month varchar2(3), year number, amount real);
    begin
    insert into ledger values (1,'jan',1980,100);
    insert into ledger values (2,'jan',1980,200);
    insert into ledger values (3,'mar',1980,300);
    insert into ledger values (4,'mar',1980,1000);
    insert into ledger values (5,'jul',1980,400);
    insert into ledger values (6,'jun',1980,500);
    insert into ledger values (7,'oct',1980,700);
    insert into ledger values (8,'oct',1980,600);
    insert into ledger values (9,'oct',1980,200);
    insert into ledger values (1,'jan',1981,100);
    insert into ledger values (2,'jan',1981,200);
    insert into ledger values (3,'mar',1981,400);
    insert into ledger values (4,'mar',1981,100);
    insert into ledger values (5,'jul',1981,300);
    insert into ledger values (6,'jun',1981,200);
    insert into ledger values (7,'oct',1981,100);
    insert into ledger values (8,'oct',1981,100);
    insert into ledger values (9,'oct',1980,100);
    insert into ledger values (1,'jan',1982,100);
    insert into ledger values (2,'jan',1982,200);
    insert into ledger values (3,'mar',1982,400);
    insert into ledger values (4,'mar',1982,100);
    insert into ledger values (5,'jul',1982,300);
    insert into ledger values (6,'jun',1982,200);
    insert into ledger values (7,'oct',1982,100);
    insert into ledger values (8,'oct',1982,100);
    insert into ledger values (9,'oct',1982,100);
    insert into ledger values (1,'jan',1984,100);
    insert into ledger values (2,'jan',1984,200);
    insert into ledger values (3,'mar',1984,300);
    insert into ledger values (4,'mar',1984,1000);
    insert into ledger values (5,'jul',1984,400);
    insert into ledger values (6,'jun',1984,500);
    insert into ledger values (7,'oct',1984,700);
    insert into ledger values (8,'oct',1984,600);
    insert into ledger values (9,'oct',1984,200);
    end;
    select  Initcap(month) "Year",
           sum(case  when year = 1980 then amount else 0 end ) "1980",
           sum(case  when year = 1981 then amount else 0 end ) "1981",
           sum(case  when year = 1982 then amount else 0 end ) "1982",
           sum(case  when year = 1983 then amount else 0 end ) "1983",
           sum(case  when year = 1984 then amount else 0 end ) "1984",
           sum(case  when year = 1985 then amount else 0 end ) "1985"
    from ledger
    group by  month;
    Expected output
    Year     1980       1981        1982        1983       1984         1985
    Jan         amount    amount   amount   amount  amount   amount
    Feb        amount    amount   amount   amount  amount   amount
    Mar        amount    amount   amount   amount  amount   amount
    Apr        amount    amount   amount   amount  amount   amount
    May       amount    amount   amount   amount  amount   amount
    Jun       amount    amount   amount   amount  amount   amount
    Jul        amount    amount   amount   amount  amount   amount
    Aug      amount    amount   amount   amount  amount   amount
    Sep      amount    amount   amount   amount  amount   amount
    Oct      amount    amount   amount   amount  amount   amount
    Nov      amount    amount   amount   amount  amount   amount
    Dec      amount    amount   amount   amount  amount   amountThanks
    Raghu

    and in case you want a proper sorting order...
    SQL> with months as
      2  (
      3       select level l, to_char(add_months(trunc(sysdate, 'yy'), level-1), 'mon') m
      4       from dual
      5       connect by level <= 12
      6  )
      7  select max(Initcap(m.m)) "Year",
      8         sum(case  when year = 1980 then amount else 0 end ) "1980",
      9         sum(case  when year = 1981 then amount else 0 end ) "1981",
    10         sum(case  when year = 1982 then amount else 0 end ) "1982",
    11         sum(case  when year = 1983 then amount else 0 end ) "1983",
    12         sum(case  when year = 1984 then amount else 0 end ) "1984",
    13         sum(case  when year = 1985 then amount else 0 end ) "1985"
    14  from ledger l, months m
    15  where l.month (+) = m.m
    16  group by m.l
    17  order by m.l;
    Year       1980       1981       1982       1983       1984       1985
    Jan         300        300        300          0        300          0
    Feb           0          0          0          0          0          0
    Mar        1300        500        500          0       1300          0
    Apr           0          0          0          0          0          0
    May           0          0          0          0          0          0
    Jun         500        200        200          0        500          0
    Jul         400        300        300          0        400          0
    Aug           0          0          0          0          0          0
    Sep           0          0          0          0          0          0
    Oct        1600        200        300          0       1500          0
    Nov           0          0          0          0          0          0
    Dec           0          0          0          0          0          0
    12 rows selected

  • How to build a query to join on two tables without mapping

    I did Automatic mapping by the workbench Directofield mapping with the table and java object.
    Wanted to build a simple join query by joining on the same field on both the tables.Not the sql query through the toplink using expression builder.
    Please help.............
    Spent one full day for this................

    Thanks Don for the reply,sorry to bug you,but i need help.....
    SELECT A.AGNCY_C,
         A.TYPE_C,
         A.RESN_C,
         A.S_TYPE_C,
         A.SUB_ID_C,
         A.RY_C
    FROM RATING A, REF B
    WHERE A.ID_C = B._ID_C
    AND A.ALPHA_C = B.ALPHA_C
    AND A.EFF_D >= B.MATURITY_D
    This is the real query i was talking about.I did mapping automatically through the workbench,generated java classes also throught the workbench.
    Now they don't want to execute the raw sql.They wanted to get all the RATING objects with the where condition.
    So how to build a query by using toplink.
    tried your example
    ExpressionBuilder builder = new ExpressionBuilder();
    Expression creditRating = builder.getTable("RATING").getField("ID_C");
    Expression issue_ref = builder.getTable("REF").getField("ID_C");
    Expression join = creditRating.equal(issue_ref);
    I am getting java.lang.OutOfMemoryError
    error.
    I selected the option generate classes and descriptors
    from the tables (RATING,REF).,so it created the classes and dscriptors automatically.
    In Database script for the table RATING like this
    ALTER TABLE RATING ADD (
    CONSTRAINT RATING_F1 FOREIGN KEY (ID_C, ALPHA_C)
    REFERENCES REF (ID_C,ALPHA_C));
    I think when i generate descriptor automatically it is keeping this association.
    Please help me.........

  • Help in the query

    hi folks,
    Help me to build the query here.
    Tables BKPF - fields belnr, blart
           BSEG - fields kunnr,wrbtr, zuonr
    I need to get the data into a single internal table whose strucutre consists of fields kunnr, blart,wrbtr and zuonr
    the common field between the two tables is belnr and the query should be run based on 'zuonr' field
    i.e
    select ......................... where bseg-zuonr = p_advnum(paramter field where I get the data)
    Question how to establish relation between two tables in asingle query without the use of 'JOIN' statements because BSEG is a cluster table and i cannot do that.
    Thanks in advance.
    Santhosh

    Here's one way, but that hit to BSEG may take a while if you don't have an index for that field.
    data: xbkpf type bkpf.
    data: ibseg type table of bkpf with header line.
    data: begin of itab occurs 0,
          kunnr type bseg-kunnr,
          blart type bkpf-blart,
          wrbtr type bseg-wrbtr,
          zuonr type bseg-zuonr,
          end of itab.
    parameters: p_advnum type bseg-zuonr.
    select * into corresponding fields of table ibseg
             from bseg
                 where zuonr = p_advnum.
    loop at ibseg.
      move-corresponding ibseg to itab.
      clear xbkpf.
      select single * from bkpf into xbkpf
              where belnr = ibseg-belnr.
      itab-blart = ibseg-blart.
      append itab.
    endloop.
    Regards,
    Rich Heilman

  • How to build a query to get the item properties is tick or not?

    hello everybody. i'm 1 of the sap b1 user. i face a problem in build a query to check one of the item properties is tick or not? pls help...

    Hi Grace,
    your query could look like this:
    Select itemcode from oitm where qrygroup1= "Y"
    qrygroup1 is item property 1, qrygroup2 is item property 2 etc.
    Regards
    Ad

  • Need help with SQL Query

    I am trying to build a query that sums up 12 columns depending on some accounting variables.
    example:
    SELECT gbmcu, gbco, gbfy,'',SUM(gban01 gban02 gban03 gban04 gban05+gban06+gban07+gban08+gban09+gban10+gban11+gban12) AS Oil_Volumes
    FROM PRODDTA.F0902
    WHERE GBCO = '00099'
    AND GBFY = 5
    AND GBLT = 'QU' AND GBOBJ = 5015 AND GBSUB = '105'
    GROUP BY gbmcu, gbco, gbfy
    The condition that changes is :AND GBLT = 'QU' AND GBOBJ = 5015 AND GBSUB = '105'
    I need to do this for 17 different conditions - I need to make the query as optimized as possible.
    I tried using a case statement but that takes forever (the table is over 4 million records to scan through).
    Please let me know if anyone has any suggestions on how to create something to perform these calculations.
    thanks,
    Pam

    I think I would tend to write that query as:
    SELECT gbmcu, gbco, gbfy,
           SUM(CASE WHEN gblt = 'QA' AND gbobj = 5015 AND gbsub = '105' THEN
                    gban01+gban02+gban03+gban04+gban05+gban06+gban07+gban08+gban09+gban10+gban11+gban12 END) Oil_Sales
           SUM(CASE WHEN gblt = 'QU' AND gbobj = 5015 AND gbsub = '105' THEN
                    gban01+gban02+gban03+gban04+gban05+gban06+gban07+gban08+gban09+gban10+gban11+gban12 END) Oil_Volumes
    FROM proddta.f0902
    WHERE gbco = '00099' and
          gbfy = 5 and
          gblt IN ('QA', 'QU') and
          gbpbj = 5015 and
          gbsub = '105'
    GROUP BY gbmcu, gbco, gbfySUM the CASE rather than CASE SUM. Also, as written, your query will look at all of the records in f0902 whether or not they meet one of the Case criteria, so I would put the required values in the WHERE clause as well. Your samples only show gblt changing, so you may need to make the gbpbj and gbsub predicates IN lists as well.
    If the query runs in 1.5 hours calculating one value, I would expect it to be about the same calculating 17 values, since I would bet that most of the run time is accessing the table rather than doing the math. It would almost certainly be faster than running essentially the same query 17 times.
    Indexes on some or all of the columns in the WHERE clause may help, depending on how selective the columns are. At a guess, I would suggest that gbco and gbfy would be good candidates.
    Finally, are you sure that gbsub is a character field? The only example we have is a number.
    HTH
    John

  • Need help in the Query

    I am trying to build a query with
    1)Customer name,Account number and monthly revenue.
    2) Customer name, Year-to -date revenue.
    I dont know which tables should i join to get the results.

    I dont know which tables should i join to get the results. Neither do we ;-).
    Without any details, no one will be able to help you.

  • Cannot build the query or generate the report. WIS 30351

    I am trying to create a docuemtn using SDK. I have created a document and when I try to add dataprovider and update the document, I am facing the below error
    Cannot build the query or generate the report. WIS 30351
    http://help.sap.com/saphelpiis_sbo41sp5wi-sdk/frameset.htm?ec5645bc6fdb101497906a7cb0e91070.html
    Any help would be appreciated...

    Hi Pirabu,
    here's the required steps for what you described:
    1. Create a new report in folder with ID 12345:
         POST ../raylight/v1/documents
         request body:
            <document>
            <name>My New Doc</name>
            <folderId>12345</folderId>
            </document>
          response:
            <success>
            <message>The resource of type "Document" with identifier "54321" has been successfully created.</message>
            <id>54321</id>
            </success>
    2. use the new document ID when adding a data provider (ie universe ID is 5543)
          POST ../raylight/v1/documents/54321/dataproviders
          request body:
            <dataprovider>
            <name>Query 1</name>
            <dataSourceId>5543</dataSourceId>
            </dataprovider>
          response:
            <success>
            <message>The resource of type "Data provider" with identifier "DP0" has been successfully created.</message>
            <id>DP0</id>
            </success>
    If you are doing something different, please provide the steps you are using and the type of datasource you are adding (unv, unx, Bex query etc).
    Is the error when adding the data provider, or do you have an additional step updating the document?
    Also, what version of BI4 are you working with?
    Dan

  • Build a query on runtime and not on design time

    Post Author: rchokler
    CA Forum: WebIntelligence Reporting
    When i build web Intelligence report the BO tool writes the Sql query includes all object I've picked up.
    I would like the TOOL not to build the hole SQL query on design time, I wand it to build the query includes only
    the objects the users picked up to display on the report (on runtime)
    Can i do it?
    BO XI  release 2 Enterprise edition

    Hi,
    As far as I know this can't be done at once because you have to consider :
    - Every Opportunity and their time-limited ProductRevenues
    AND
    - Time-limited Opportunities
    If you want to achieve this, you have to consider the 2 datasets separately and make your first query :
    ObjOpptyQueryPageInput.ListOfOpportunity.Opportunity.searchspec = "([ModifiedDate] >= '01/01/2013 00:00:00')";
    but also another query with the restriction on the ProductRevenue Searchspec.
    This shouldn't be too hard because the searchspec functionality is present at each level :
    - ListOfOpportunity -> Opportunity (the top-level that you used for your query)
    - ListOfOpportunity -> Opportunity -> ListOfProductRevenue -> ProductRevenue (the sub-level that you should use for the second query)
    Then in your C# code, you merge the 2 datasets and you end up with your expected result.
    Hope this helps,
    Charles.
    http://www.dubant.com

  • SQVI or SQ01 - Building a Query

    I am looking to build a query in SQ01 or SQVI to list the following:
    1. List of all the customer numbers
    2. List of all agreement numbers
    3. List of customer with associated agreement
    4. List of all addresses.
    WHile the Query 1 is for Business partner... which is the table i can use.
    Is it BUT000 or i need to join more than one table.
    Query 2 - refers to Total commitment in SAP. I don't know the table details.
    Query 3 - Refers to the combination of SAP Business Partner data and Total commitment data.
    Query 4 -  Seems to be the address in Business partner. Which is the appropriate table.
    help me in tbuilding this query.

    Hi,
    Is requirement part of the FSCD module, if you let me know I can help you on that.  Please more specific with your requirement.
    I am currently working on FSCD module as an ABAP consultant.
    Thanks,
    Mahesh.

  • Can I build a query to show monthly sales by item by business partner?

    Hi all
    Is it possible to build a query to show monthly sales (quantity not value) by item by business partner?
    So the table would look something like this.
                   Jan     Feb     Mar     Apr
    Item 1      10       4         8         7
    Item 2      4         3         5         6
    Item 3      4        12        9         3
    Item 4      1         0         1         2
    Etc...
    As you can see, the monthly figure needs to be quantity of the item and not sales value.
    Would be grateful for any help.
    Many thanks.
    Wendy

    Hi,
    Try this:
    declare @code as varchar(15)
    set @code = ( select max(ta.cardcode) from OINV ta where ta.cardcode = [%0])
    Select [a] as Cardcode, [B] as Cardname, [c] as Item#, [D] as Descr,[1] as Jan,[2] as Feb,[3]as Mar,[4] as April,[5] as May,[6] as June,[7] as July ,[8] as Aug,[9] as Sept,[10] as Oct ,[11]as Nov,[12] as Dec
    from(
    SELECT T0.[CardCode] as  A , T0.[CardName] as  B, T1.[ItemCode] as C, T1.[Dscription] as D, sum(T1.[Quantity]) as t,month(T0.[DocDate]) as month FROM OINV T0  INNER JOIN INV1 T1 ON T0.DocEntry = T1.DocEntry WHERE year( T0.[DocDate]) = 2014 and t0.cardcode = @code GROUP BY T0.[CardCode], T0.[CardName], T1.[ItemCode], T1.[Dscription],T0.[DocDate] ) S
    pivot
    (sum(t) for month IN ([1],[2],[3],[4],[5],[6],[7],[8],[9],[10],[11],[12])) P
    Thanks & Regards,
    Nagarajan

  • How to build sql query for view object at run time

    Hi,
    I have a LOV on my form that is created from a view object.
    View object is read-only and is created from a SQL query.
    SQL query consists of few input parameters and table joins.
    My scenario is such that if input parameters are passed, i have to join extra tables, otherwise, only one table can fetch the results I need.
    Can anyone please suggest, how I can solve this? I want to build the query for view object at run time based on the values passed to input parameters.
    Thanks
    Srikanth Addanki

    As I understand you want to change the query at run time.
    If this is what you want, you can use setQuery Method then use executeQuery.
    http://download.oracle.com/docs/cd/B14099_19/web.1012/b14022/oracle/jbo/server/ViewObjectImpl.html#setQuery_java_lang_String_

  • How to build a query based on(UNION) 3 vendor InfoObject

    Dear Experts:
    I have a requirement to build one query based on 3 vendor InfoObjct: 0VENDOR + 0VEN_COMPC + 0VEN_PURORG.
    I tried to build a multiprovider upon these 3 infoobjects, but when I Identify(Assign) the key for each InfoObject, supposely there should be 3 InfoObject for me to check (0VENDOR, 0VEN_COMPC and 0VEN_PURORG) so that I can UNION these 3 infoobjects together on vendor number. But since the reference infoobject of these 3 vendor master data is different, I can not check the 3 together.
    Can anybody let me know how to build that query? I only need vendor number show once, and the attributes of 0VEN_COMPC and 0VEN_PURORG can be union to 0vENDOR.
    Any post would be appreciated and thank you all in advance!
    Best Regards!
    Tim

    Hi,
    you can create a link between the vendor objects itself, means link 0vendor with 0ven_compc and 0ven_purorg. This should give you a list of all vendors multiplied with the comp codes multiplied with the purch. org. May be here it is possible to create another link between a attribute (eg. comp_code of 0ven_purorg with comp_code of 0ven_compc). In case it is not possible you need to add this link information somehow. Another option might be to create 2 queries. One on a infoset of 0vendor and 0ven_purorg and another one on 0vendor and 0ven_compc.
    regards
    Siggi

Maybe you are looking for

  • Smartform Mail -DOCUMENT_NOT_SENT Exception

    Hi , We are using the FM - SO_NEW_DOCUMENT_ATT_SEND_API1 to send a smartform mail with PDF attachement, we are able to acheive this in the Developement system, where as in Quality system this FM is raising exception DOCUMENT_NOT_SENT (sy-subrc = 2).

  • Whitelist a whole domain in IronPort C370?

    Hi! I have a customer that can't send emails to us cause of bad reputation.  Not sure how am going to whitelist their domain. Their domain is: domainABC.com Their SMTP servers is A.domainXYZ.com, B.domainXYZ.com, C.domainXYZ.com. What should i put in

  • Tool Tip for a screen field.

    Hi, I have a step loop defined in a screen. I want to show tool tip for the each column. Please let me know how can i do it? I would really appreciate it. Regards, Sanjeev

  • Doble click event in visio

    Hello everybody. I have a question I have a code that change the width and height of a shape when user click in a shape and I want that  when the user click a shape change the width and height of a shape, and when the user click again same shape, cha

  • Cannot see the components in ESS after import it into CBS

    Hi all: After we import ESS 100 ( in ECC ) into JDI. Then in NWDS we can see the configuration, but we cannot see the components inside the ESS repository. In CMS - Transport Studio, we have done the check-in, Development, Consolidation, there are al