Distinct values as input to another query

Can any one help me to write a program to fetch distinct values in query and then insert that distinct values as input to another query

Fetch distinct values:
use distinct keyword
for insert : use the following.
insert into <table_name> select distinct <column_names> from <table_name>;

Similar Messages

  • How to use output of a Query as an input to another Query

    Dear BI experts,
    We have a unique requirement. We are multinational company and employees moving from Country to another.
    I have created a Bex query to give me the list of countries that employees have been since they joined the company. The columns in the report are PERNR, date_from  and country.
    When I run the query for all employees it gives us the list of countries that each employee was present.
    Now the requirement is to show only the employees who have been at least once in UK. This list should contain all the countries they were living in addition to UK.
    I cannot put a condition in the u2018Countryu2019 column for u2018UKu2019 since it will give me only UK and will not list other countries.
    Could you please provide me with a solution.
    I thought of running 2 queries to get the desired result. First run a report with a condition that Country = UK. This will give the list of employees who have been in UK at least once. Run the second query by using the list of employees from he first query without any restrictions. But the question is how to make the list of employees in the first query as an input to the second query, other than manually adding it in the selection screen.
    Hope I was able to explain the requirements clearly.\
    Thanks in advance to your suggestions.
    Regards,
    Sai

    Hi Sainath,
    This can be acheived by RRI i.e report to Report Interface !!!!!!
    T Code -RSBBS.
    Report A-Jump to report B.
    Report B-Is Employee Based
    Assume u want call report B from Report A
    1)GOTO RSBBS
    2)Create New
    3)Sender Query Give the First Query Report A
    4)Below sender Query there is Receiver Query  give the RRI query report B (The query which u want to call).Report type should be BEX ,and Target system--Assign the System(Local) and in the report give the Report B.
    5)In the Report A check whether in the GOTO -u get the Receiver Query ,i.e Report B.
    In the Assignments in RSBBS set the Emp Infoobject as Delete instead of Generic and create a Input Variable for Employee in Report A.
    Come bak if u have any issues
    Rgds
    SVU123

  • Need to use the results of one query as an input to another query

    Hi, I have one sql query in my XML file, that returns more than one values for a column.
    and i want to use this output one by one as an input to the second query to retrive the data from the second query.
    Could please someone tell me if its possible in XML Publisher?
    If possible, please share the syntax to do the same
    For eg:
    Query 1:
    Select data1, data2 from query1 ; -- output data1 and data2
    want to use data1 and data2 one by one in the below query
    Query 2:
    select * from abc where name_id= data1/data2;
    Thanks and Regards
    Madhu

    Make sure your cursor declarations are in your declare section, not between the begin and end statements.

  • How to use one query results in another query

    hi,
    in help.sap I have founded that using variable type replacement path I can use one query results in another query. It is wrote there that I have to choose query name results I want to get in variable definition but I do not know where.
    How I can do this?
    Result I want to get is:
    In one query I have material prices in another material quantities. I want to calculate inventory value (price * quantity). Moreover prices are on plant level, quantities on storage type level. Plant is atribute of storage type.
    Can I do this?
    Regards,
    Andrzej

    Hi Andrzej,
    please check out this thread: Set parameters values depending on other parameters
    I had a discussion about query results as input for another query in there.
    For creating a workbook, just click on the save button after you ran your query in the bex.
    Siggi
    Message was edited by: Siegfried Szameitat

  • Need of SQL query in selecting distinct values from two tables

    hi,
    I need a query for selecting distinct values from two tables with one condition.
    for eg:
    there are two tables a & b.
    in table a there are values like age,sex,name,empno and in table b valuses are such as age,salary,DOJ,empno.
    here what i need is with the help of empno as unique field,i need to select distinct values from two tables (ie) except age.
    can anybody please help me.
    Thanks in advance,
    Ratheesh

    Not sure what you mean either, but perhaps this will start a dialog:
    SELECT DISTINCT a.empno,
                    a.name,
                    a.sex,
                    b.salary,
                    b.doj
    FROM    a,
            b
    WHERE   a.empno = b.empno;Greg

  • I have SSRS parametarized report in that one data set have repeated values with query parameter . but while am mapping that query parameter to report parameter i need to pass distinct values. How can i resolve this

    I have SSRS parametarized report in that one data set have repeated values with query parameter . but while am mapping that query
    parameter to report parameter i need to pass distinct values. How can i resolve this

    Hi nancharaiah,
    If I understand correctly, you want to pass distinct values to report parameter. In Reporting Service, there are only three methods for parameter's Available Values:
    None
    Specify values
    Get values from a query
    If we utilize the third option that get values from a dataset query, then the all available values are from the returns of the dataset. So if we want to pass distinct values from a dataset, we need to make the dataset returns distinct values. The following
    sample is for your reference:
    Select distinct field_name  from table_name
    If you have any other questions, please feel free to ask.
    Thanks,
    Katherine Xiong
    Katherine Xiong
    TechNet Community Support

  • Problem when Entering Decimal Values at Input Ready Query

    Hi Everyone,
    I have created Input ready query but when I am going to enter decimal values in input cell it takes as a round of value.
    Example:- If I enter 1.234 value at input cell it takes as a 1 or if I enter 1.789 value then it takes as a 2 at cell.
    The technical properties of Key Figure at Info object level is,
    Radio Button :- Decimal
    Drop Down :- FLTP (Floating Point)
    But we want to whatever value will enter at input cell, the same value will save at real time info cube level.
    Requirement :- If I enter 1.234 value at input cell it needs to take as a 1.234
    Please suggest your comments/views.
    Thanks
    Kind Regards
    Anukul

    Hi Giradkar,
    Check the setting of the UOM you are using in table 'T006' there are 2 fields that indicate how to display and how to store the values with respective UOM.
    Regards,
    Eitan.

  • Issue with Results from Another Query (Error on Null value)

    Hi All,
    We have a WebI report using "Result from Another Query" option of BO XI R3.1. The report was running fine till recently the dimension object using result from another query had a null value. Report suddenly throwed error as the query filters are invalid.
    Is there a way to make this filter optional if no data/null value is there ? Because we need those null values in report as well.
    Thank you for your time.
    Thanks & Regards
    LN

    Hi Vivek,
    It was not directly solved but I applied alternate logic to over come the issue.
    Here's what I did to overcome:
    I used a sub query in place of the whole result from another query.
    For Ex:
    Dim1 inlist result from another query1
    I made it as
    Dim1 inlist (Dim0)
    where Conditions.
    Here Dim0 is the object which we use for Result from another query and Conditions will be the necessary filter conditions to arrive proper Dim0.  Make sure proper context is formed for the sub query.
    Even though it resolved my problem, It introduces an new issue. It causes increase in query run time when huge set of data is returned from sub query.
    Please let me know if i haven't explained clearly.
    Hi Aris_BO,
    Sorry for not responding earlier.  The logic would probably make more queries null & not null. Thats why I was not advised to use it.
    Thanks
    LN

  • How to use output of one query as an input for another

    Hi Gurus,
    can you give me any links on how to use an output of one query as an input for another (preferably if this can be done in a dynamic/on the fly way)?
    thanks

    You can use Replacement Path Variable for this purpose. See this detailed documentation.
    http://help.sap.com/saphelp_nw04s/helpdata/en/bd/589b3c494d8e15e10000000a114084/content.htm
    Abhijit
    Edited by: ABHIJIT TEMBHEKAR on Nov 19, 2008 9:48 AM

  • Saving values of a query to do another query

    Hello:
    I have two selectOneChoice in a page. When you select in the first SelectOneChoice, the second one shows the values obtained by a query. This works perfectly.
    Now with the second value of the SelectOneChoice I have to do another query to get values for another query. I would like to save this values in a variable to use them in the next query and create a table with the resutl of the query.
    Some ideas? I haven´t be able to get this
    I have get to execute the query. In the PageDef I have created a variable (codEnf) and a iterator (findCodEnfByIdIter) in the executables. In the bindings I have created an methodAction(findCodEnfById) and a List (findCodEnfById1). In the console i see that the query is executing correctly. If I put a new component referencing to this, all is correct. But.... How to save the result in the variable codEnf??
    I have put a OutputText in the page with value #{bindings.codEnf} and it´s empty...
    Why?
    Message was edited by:
    ALF

    Help please!!!!!!!!

  • Is it possible to display default values in input ready query.

    Hi Guys,
    Is it possible to display default values in input ready query.

    HI,
    Select the particular Variable.....in the right hand side u will find the default values tab....in that u can give the values...and save...if u run the query then it will show the default values for that Variable.selection....
    Thanks/Tarak

  • Get distinct values from a coma seperated string variable

    Hi ,
    I am getting an comma seperated string as in parameter, now i want to get the distinct values from that string and will use those values to pass it to a query.
    any help

    try this:
    sorry about the messiness - it's just quickly copied from some badly formatted code....
    TYPE T_FieldArray IS TABLE OF varchar2(255) INDEX BY BINARY_INTEGER;
    function SPLIT_CSV_FIELDS (
    p_Input_Str in varchar2,
    p_Delimiter in varchar2,
    p_Quote_Char in varchar2)
    return t_fieldarray is
    v_FieldArray T_FieldArray;
    v_input_str varchar2(4000);
    v_field_str varchar2(255);
    v_pos number;
    e number := 0;
    v_delim_str varchar2(3);
    cur_pos number;
    begin
    loop
    -- find each delimiter char in string
    v_pos := INSTR(v_input_str, p_Delimiter);
    -- each time delimiter char is found
    if v_pos > 0 then
    -- current field value is current string to position prior to delimiter char
    v_field_str := UPPER(SUBSTR(v_input_str, 1, v_pos - 1));
    -- remove quote char from end of field (if any)
    v_field_str := TRIM(TRANSLATE(v_field_str, NVL(p_Quote_Char, p_Delimiter), ' '));
    -- increment element number
    e := e + 1;
    -- get remainder of input string to check
    v_input_str := SUBSTR(v_input_str, v_pos + 1, LENGTH(v_input_str) - v_pos);
    v_FieldArray(e) := v_field_str;
    else
    -- increment element number
    e := e + 1;
    -- last field value is what's left of input string less quote char (if any)
    v_field_str := TRIM(TRANSLATE(UPPER(v_input_str), NVL(p_Quote_Char, p_Delimiter), ' '));
    v_FieldArray(e) := v_field_str;
    exit;
    end if;
    end loop;
    return v_FieldArray;
    end;

  • "How to get distinct values of sharepoint column using SSRS"

    Hi,
        I have integrated sharepoint list data to SQL Server reporting services. I am using the below to query sharepoint list data using sql reporting services.
    <Query>
       <SoapAction>http://schemas.microsoft.com/sharepoint/soap/GetListItems</SoapAction>
       <Method Namespace="http://schemas.microsoft.com/sharepoint/soap/" Name="GetListItems">
          <Parameters>
             <Parameter Name="listName">
                <DefaultValue>{GUID of list}</DefaultValue>
             </Parameter>
             <Parameter Name="viewName">
                <DefaultValue>{GUID of listview}</DefaultValue>
             </Parameter>
             <Parameter Name="rowLimit">
                <DefaultValue>9999</DefaultValue>
             </Parameter>           
          </Parameters>
       </Method>  
    <ElementPath IgnoreNamespaces="True">*</ElementPath>
    </Query>
    By using this query, I am getting a dataset which includes all the columns of sharepoint list. Among these columns, I wanted to display only 2 columns (i.e Region and Sales type) using chart. I have created a Region parameter but when I click preview, the drop down box is giving me all the repeatative values of region like RG1,RG1,RG1,RG2,RG2,RG2,RG2,RG3.......... I wanted to display only distinct values of Region parameter so that whenever end user select region from the parameter drop down, it will display the respective value of Sales type column.
    Also when I select only RG1 parameter, it is giving me a chart including the sales type of all the Regions. (it should display me only the sales type of RG1) How can I link these 2 columns so that they will display the values respectively.
              I would really appreciate if anyone can help me out with this.
    Thanks,
    Sam.

    Hi Sam,
    By code, the CAML language doesn’t have any reserved word (or tag) to set this particular filter to remove duplicate results.
    In this case, we could use the custom code to get distinct records.
    Here are the detailed steps:
    1.         Create a hidden parameter that gets all the records in one field.
    Note: Please create another dataset that is same of the main dataset. This dataset is used for the parameter.
    2.         Create a function that used to remove the duplicate records.
    Here is the code:
    Public Shared Function RemoveDups(ByVal items As String) As String
    Dim noDups As New System.Collections.ArrayList()
    Dim SpStr
    SpStr = Split(items ,",")
    For i As Integer=0 To Ubound(Spstr)
    If Not noDups.Contains(SpStr(i).Trim()) Then
    noDups.Add(SpStr(i).Trim())
    End If
    Next
    Dim uniqueItems As String() = New String(noDups.Count-1){}
    noDups.CopyTo(uniqueItems)
    Return String.Join(",", uniqueItems)
    End Function
    3.         Create another parameter that will be used for filtering the maindata.
    Please set the available value to be =Split(Code.RemoveDups(JOIN(Parameters!ISSUE_STATUS_TEMP.Value, ",")), ",")
    And the default value to be the value you what such as the first value:
    =Split(Code.RemoveDups(JOIN(Parameters!ISSUE_STATUS_TEMP.Value, ",")), ",").(0)
    4.         Go to the main dataset. Open the property window of this dataset.
    5.         In the “Filters” tab, set the filter to be:
    Expression: <The field to be filter>
    Operator: =
    Value: =Parameters!Region.Value
    The parameter “Region” should be the parameter we created in the step3.
    Now, we should get distinct values of SharePoint columns.
    If there is anything unclear, please feel free to ask.
    Thanks,
    Jin
    Jin Chen - MSFT

  • Multiple value selection from a base query to jump query in Web

    Hi ,
    System info
    SAP BW 3.5               level-9
    PI_BASIS -2004_1_640     level-8
    SAP_ABA  -640            Level-11
    SAP_BASIS-640            Level-11
    We have an inventory query with Profit Center,Plant & Material as characteristic. When we run the query, for example we get 10 materials for a plant. We want to keep those materials as filter value for material & want to jump to another query. The Jump query will only execute for those selected materials.
    We can able to do the above scenario in BW BEx analyzer but we are not able to do in the web. Any input to resolve the issue are welcome.
    example
    Query A
    Profit Center     Plant  Material
    PC12345          P542     M1
    PC12345          P542    M2
    PC12345          P542    M3
    PC12345          P542     M4
    PC12345          P542     M5
    PC12345          P542     M6
    PC12345          P542     M7
    PC12345          P542     M8
    PC12345          P542     M9
    PC12345          P542     M10
    Select M1 to M10 & right click "Keep filter value"
    Then remove Material from the drilldown.
    The query looklike this:
    Query A
    Material M1....M10
    Profit Center     Plant 
    PC12345          P542     
    Then right click on P542 "Goto" jump query B.
    Query B get executed on those selected materials(M1...M10) as we have a material variable in query B which is mandatory.
    In a nut we are selecting more then one value & going to another query.
    Regards
    Mahendra

    when u select KEEP FILTER VALUE at tat instance u can select only 1 value
    HOW DID U SELECT   M1 & M10 bot within one hit.
    instead of using this option.... did u try restriction
    wat i mean is when u know before hand that u need only m1 & m10
    remove material first from the display
    it will automatically reside in Free chars
    right click material and hit RESTRICT
    select m1 &  m10
    hit okey
    now u will see desired result...
    now try jump query...
    try removing the material variable from query b , just for experiementing purpose
    and then repeat above exercise...
    let us know how u go with it

  • Output of one report is input to another report?

    Hi Expert's,
    Is it possible to use output of one report as an input to another report.I mean to say  fields which are avialble in the first report  is used as a input for another report.
    Thanks,
    vasu.

    Hi,
    Yes, you can do that.
    You can run a first report having characteristics as output. You can then use the returned cahracteristic values as input variable for a second query.
    You can achieve this by creating a replacement path (based upon your first query) variable in the second report.
    Another option would be to use the report to report interface (RRI).
    hope this helps,
    Olivier.

Maybe you are looking for

  • Optimisation, Shapes and paint

    Hi, I was wondering which code saves up the most ram (technically speaking) and which is faster!! This: g2.setColor(Color.red); someShape = new Rectangle2D.Double(0, 0, 50, 50); g2.fill(someShape); someShape2 = new Rectangle2D.Double(75, 75, 50, 50);

  • Blind Network

    Hey everyone, I work on a mac (OS X, 10.4, G4.) in windows environment. Recently I needed to connect to the shared network first time, but when connected, the network seems empty, not a file insight. When I tryed to upload files, it didn't work eithe

  • How to edit PSA and continue the load with corrected data from PSA.

    Hi, Can you guide me on how to edit data in PSA and then continue a load? i.e. if you can provide me with the steps on how to fix a load problem if a load fails. The load fails and Monitor shows red, so how do I fix them in the PSA and then allow the

  • Lumia 1520 firmware update

    I have Lumia 1520 RM-937 with firmware revision 1028.3534.1343.0001, my product code is 059V3K1. When am I going to get new firmware update, which is as I found on internet 1028.3562.1402.00xx? Thanks.

  • Can you adjust APC & A/D thru revaluation?

    Hello, I want to adjust APC & Accum Deprec together with the same value thru Revaluation t-code ABAWN.. or any std. SAP tcode. I know SAP doesnot allow you to post to these b/s recon accounts directly. For eg. Asset #1 Original APC = 10,000, A/D = 50