How to get accurate values for select statement using single column

Hi All,
Below is my query which runs fine
Select Distinct Top 4
FiscalYearId,
FiscalMonthOfYearId
From ODS.Common.tODS_Date
Inner Join
UTL.Utility.tUTL_ProcessDate
On tODS_Date.DateShort < tUTL_ProcessDate.ProcessDate
And tUTL_ProcessDate.DatabaseName = 'ODS'
Order By
FiscalYearId Desc,
FiscalMonthOfYearId Desc
Below is the generate output
FiscalYearId FiscalMonthOfYearId
2014 2
2014 1
2013 12
2013 11
But i want to use this query in one of my where clause condition as its being used in the where clause it can only return 1 row.So, i tried something like this
Select Distinct Top 4
FiscalMonthOfYearId
From ODS.Common.tODS_Date
Inner Join
UTL.Utility.tUTL_ProcessDate
On tODS_Date.DateShort < tUTL_ProcessDate.ProcessDate
And tUTL_ProcessDate.DatabaseName = 'ODS'
Order By
FiscalMonthOfYearId Desc
And the result set of this one gives me the output like
FiscalMonthOfYearId
12
11
10
9
Which is not correct,( if you see the result set above). 
Can someone please help me with any ides on this.

If you want to use this query in the WHERE clause, then use it with EXISTS option which allows to return more than 1 column. 
For every expert, there is an equal and opposite expert. - Becker's Law
My blog
My TechNet articles

Similar Messages

  • How to get a value for Select One Choice in the backing bean

    Friends,
    Does any one have any idea, how to get the value of a selected item value from the Select One Choice component in the backing bean iin valueChangeListener method. Right now I am always getting the sequence of the selected item, instead the actual selected value. I tried using 'ValuePassTrhough=true' also.. but didn't help
    Below is the my code snippet
    <af:selectOneChoice value="#{bindings.country.inputValue}"
    required="#{bindings.country.hints.mandatory}"
    shortDesc="#{bindings.country.hints.tooltip}"
    id="soc1" autoSubmit="true" valuePassThru="true"
    valueChangeListener="#{pageFlowScope.Bean.onValueChange
    <f:selectItems value="#{bindings.country.items}" id="si2"/>
    </af:selectOneChoice>
    Thanks in advance.

    check my other post at Re: Pass data from a variable to another page

  • How to get the values of Select-options from the screen.

    The value of parameter can be obtained by function module 'DYNP_VALUES_READ' but How to get the values of Select-options from the screen? I want the F4 help values of select-options B depending on the values in Select-option A.So I want to read the Select-option A's value.

    Hi,
    Refer this following code..this will solve your problem...
    "Following code reads value entered in s_po select options and willprovide search
    "help for s_item depending upon s_po value.
    REPORT TEST.
    TABLES : ekpo.
    DATA: BEGIN OF itab OCCURS 0,
    ebelp LIKE ekpo-ebelp,
    END OF itab.
    SELECT-OPTIONS   s_po FOR ekpo-ebeln.
    SELECT-OPTIONS s_item FOR ekpo-ebelp.
    INITIALIZATION.
    AT SELECTION-SCREEN ON VALUE-REQUEST FOR s_item-low.
      DATA:
      dyn_field TYPE dynpread,
      temp_fields TYPE TABLE OF dynpread,
      zlv_dynpro TYPE syst-repid.
      zlv_dynpro = syst-repid.
      CALL FUNCTION 'DYNP_VALUES_READ'
        EXPORTING
          dyname     = zlv_dynpro
          dynumb     = syst-dynnr
          request    = 'A'
        TABLES
          dynpfields = temp_fields
        EXCEPTIONS
          OTHERS     = 0.
      LOOP AT temp_fields INTO dyn_field.
        IF dyn_field-fieldname EQ 'S_PO-LOW'.
            SELECT * INTO CORRESPONDING fields OF TABLE itab FROM ekpo
            WHERE ebeln EQ dyn_field-fieldvalue.
            EXIT.
        ENDIF.
      ENDLOOP.

  • A^b = n ,How to get the value for a ?

    a^b = n ===> n = Math.pow(a,b)
    How to get the value for a ?
    dose Java have API to get the value for a ?
    Thanks for help~~~

    a^b = n
    =>
    a = n^(1/b)
    So,
    a = Math.pow(n,1.0/b)

  • How to get default values on selection screen(multiple ranges)?

    i want to know how to maintain default ranges in selection screen...like 2000 to 3000 and 7000 to 8000 and 11000 to 15000
    all the above ranges must get by default how to provide those to selection screen by default...please give me idea...with example...

    Hi Suresh,
    You can either use select-options or Ranges. If you want the selection screen to be displayed with allwoing user to enter values apart for the default ones use select options else use ranges. With ranges what ever values use hard code would be set and the end user will not be able to add any more values (or range of values).
    Simply write the following code
    tables : <name of the table from which the field belongs>
    select-options <fieldname> for <tablename>-<fieldname>.
    <fieldname>-sign = 'I'.
    <fieldname>-option = 'BT'.
    <fieldname>-low = '7000'.
    <fieldname>-high = '8000'.
    append <fieldname>..
    similiarly add all the ranges that you need to include as default and in your select statement use the IN operator inthe where clause to include the range.
    If using range replacethe select-option with the range statement.
    Thanks.

  • How To get Characteristic values for an Equipment in a particular Class ?

    Hi All,
    How i will get  Characteristic values for an Equipment in a particular Class ?
    Any table or FM ?
    Thanks in advance
    Srikanta Gope

    Hi,
    You can use the FM BAPI_OBJCL_GETDETAIL to fetch the characteristic values for an equipment from the table parameters ALLOCVALUESNUM; ALLOCVALUESCHAR; ALLOCVALUESCURR.
    Or u can use the tables EQUI, KLAH, KSSK, AUSP, CABN
    Regards,
    Aditya

  • How to get the values for the Authorization Object Fields....

    Hi Everyone,
    I'm pretty new to the SAP Security and have been working on the Basis sides...I created a new role in PFCG and added a few transactions (ME13) and clicked on the Authorizations tab. In there, the authorization tree is in yellow and red. After providing the Org Values, only the yellow lights remain (apart from the green one ofcourse). Now how do we get the values for the different auth obj fields that are in yellow... say for example
    Conditions                                                   COND
    Maintain Condition: Auth. for Use/Appl./Cond.Type/Table      V_KOND_VEA
    Activity                       03                                                                        ACTVT
    Application                                                                                KAPPL
    Condition table                                                                                KOTABNR
    Condition Type                                                                                KSCHL
    Usage of the condition table                                                                 KVEWE
    Here the values for V_KOND_VEA fields e.g. KAPPL, KOTABNR etc are missing.
    My question is how do we get these values in regard to the requirement provided by the client...is it the functional guys who provide these values or else how is a security person supposed to know it...
    All the help in this regard is sincerely appreciated along with the awarding of points...

    Hey thanks Alex and Catastrophe for the quick response...
    I'll be sitting with the functional team and reviewing the roles created.
    Thanks for all the help once more
    Regards,
    Akash.

  • How to get the value of Selected Dimension in a Pie Chart ?

    Hi All,
    Here is an example i'm working on ,
    JS Bin - Collaborative JavaScript Debugging&lt;/title&gt; &lt;link rel=&quot;icon&quot; href=&quot;http://static.jsbin.…
    I'm using selectData event to fire when any data is selected in the chart. How to get the value of dimension, in my case country which has been selected ?
    Thanks & Regards
    Sakthivel

    Hi,
    I added below code
    var oSelectData = oEvent.getParameter("data");
    // let the dataset convert the event coordinates back to a UI5 model context
    var oContext = this.getDataset().findContext(oSelectData[0].data[0].ctx.path);
                   console.log(oContext);
    in console  I am able to get the path of selected dimention.
    JS Bin - Collaborative JavaScript Debugging&lt;/title&gt; &lt;link rel=&quot;icon&quot; href=&quot;http://static.jsbin.…
    you can figure out how to get the data from this information.
    Regards,
    Chandra

  • How to get the value for the LIT_Withheld field in the city tax form?

    I am trying to get the value for the LIT_Withheld field on the city tax form , PAYUSEET.. This is not a database column but is generated based on some conditions.. Appreciate the help. Thanks, Suguna

    Hi Abhmanyu,
    Thanks for your response.
    Search Help Name : ZZ_MG_MARITAL_VH
    Selection Method  : T502T
    Search help parameters are SPRSL, FAMST, FTEXT,
    Can u provide me a sample code to fetch the value of corresponding text.
    Thanks,
    Hari

  • How to restrict the values for selection in the search help..

    hi,
    i have a requirement regarding screen programming. i have added a i/o field in a screen and i linked a search help for that field.
    i used the standard search help it holds some 15 values for selection...
    when i click on the  search help i m getting some 15 values for selection. but i dont need all the 15 values. i need only 4 values for selection..can any one help me regarding this...
    waiting for ur reply...
    Uday.
    Edited by: uday13 on May 31, 2010 9:17 AM

    Hello,
    Refer the below code and you can provide your own search help to a parameter depending on the value in another parameter:-
    PARAMETERS : p_belnr TYPE belnr,
                 p_bukrs TYPE bukrs.
    DATA : BEGIN OF itab OCCURS 0,
             bukrs TYPE bukrs,
           END OF itab.
    AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_bukrs.
      PERFORM f4_bukrs_help USING p_bukrs.
    *&      Form  f4_bukrs_help
    FORM f4_bukrs_help USING p_bukrs.
      DATA : itab TYPE STANDARD TABLE OF it WITH HEADER LINE,
             tb_dynpfields LIKE dynpread OCCURS 0 WITH HEADER LINE,
             v_belnr TYPE belnr.
      CLEAR:   tb_dynpfields.
      REFRESH: tb_dynpfields.
      MOVE 'P_BELNR' TO tb_dynpfields-fieldname.
      APPEND tb_dynpfields.
      CALL FUNCTION 'DYNP_VALUES_READ'
        EXPORTING
          dyname                               = 'Z_F4' "program name
          dynumb                               = '1000' "screen number
        TABLES
          dynpfields                           = tb_dynpfields
      IF sy-subrc NE 0.
      ENDIF.
    READ TABLE tb_dynpfields INDEX 1.
      IF sy-subrc EQ 0.
        v_belnr = tb_dynpfields-fieldvalue.
      ENDIF.
      SELECT bukrs from <db_table> INTO TABLE itab WHERE belnr = v_belnr.
      CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST'
        EXPORTING
          retfield               = 'BURKS' "internal table field
          dynpprog               = 'Z_F4' "program name
          dynpnr                 = '1000' "screen number
          dynprofield            = 'P_BUKRS' "screen field name
          value_org              = 'S'
        TABLES
          value_tab              = itab "internal table
      IF sy-subrc NE 0.
      ENDIF.
    ENDFORM.                    " f4_bukrs_help
    Hope this helps you.
    Regards,
    Tarun

  • How to get the values for checked and unchecked chekboxes

    Hai i have using the checkbox in for loop.
    I need the urgent help from anyone,
    for example in the loop there is having 5 checkbox if i checked 3 of the ckeckboxes and 2 of the checkboxes are unchecked. I need to get the values for checked checkboxes and unchecked checkboxes. Because if i checked the checkboxes, those values need to be inserted into the database. Those for unchecked checkboxes values need to be deleted from the database. Can anyone help me for this
    i am using the following jsp code for this. If anyone can know about this please post me the sample code.
    <form name="confirmcontainer" id="confirmcontainer" method="post" action="submit.jsp">
    <% for(int i=0;i<value.length;i++) {%>
    <tr>
    <td><input name="assigncontainer_chkbox" d="assigncontainer _chkbox" type="checkbox" value="<%=value[0]%>"></td>
    <td class="bottomborder"><div align="center"><font size="2" face="Verdana, Arial, Helvetica, sans-serif"><%=value[1]%> </font></div></td>
    <td bgcolor="#FFFFFF" class="bottomborder"><font size="2" face="Verdana, Arial, Helvetica, sans-serif"><%=value[2]%></font></td>
    </tr>
    <% } %>
    <tr><td><input type="submit" name="submit" value="submit"> </td></tr>
    </form>
    Thanks & Regards,
    Tamilvanan

    Hey thanks Alex and Catastrophe for the quick response...
    I'll be sitting with the functional team and reviewing the roles created.
    Thanks for all the help once more
    Regards,
    Akash.

  • Need to Improve  pefromance for select statement using MSEG table

    Hi all,
    We are using a select statement using MSEG table
    which takes a very long time to run the program which is scheduled in back ground.
    Please see the history below.;
    1) Previously this program was using SELECT-ENDSELECT statement inside the loop i.e.
    LOOP AT I_MCHB.
    To get Material Doc. Details
          SELECT MBLNR
                 MJAHR
                 ZEILE INTO (MSEG-MBLNR,MSEG-MJAHR,MSEG-ZEILE)
                 UP TO 1 ROWS
                 FROM MSEG
                WHERE CHARG EQ I_MCHB-CHARG
                 AND  MATNR EQ I_MCHB-MATNR
                 AND  WERKS EQ I_MCHB-WERKS
                 AND  LGORT EQ I_MCHB-LGORT.
          ENDSELECT.
    Endloop.
    The program was taking 1 hr  for  20 k data
    2)The above statement was replaced by ALL ENTRIES to remove the SELECT-ENDSELECT from the loop.
    ***GET MATERIAL DOC NUMBER AND FINANCIAL YEAR DETAILS FROM MSEG TABLE
        SELECT MBLNR
               MJAHR
               ZEILE
               MATNR
               CHARG
               WERKS
               LGORT
                   INTO TABLE I_MSEG
                   FROM   MSEG
                   FOR ALL ENTRIES IN I_MCHB
                   WHERE CHARG EQ I_MCHB-CHARG
                   AND   MATNR EQ I_MCHB-MATNR
                   AND   WERKS EQ I_MCHB-WERKS
                   AND   LGORT EQ I_MCHB-LGORT.
    3)After getting the further technical analysis from BASIS team , And with the suggestion to optimize the program by changing the INDEX RANGE SCAN to
           MSEG~M.
    SELECT MBLNR
               MJAHR
               ZEILE
               MATNR
               CHARG
               WERKS
               LGORT
                   INTO TABLE  I_MSEG
                   FROM   MSEG
                   FOR ALL ENTRIES IN I_MCHB
                   WHERE MATNR EQ I_MCHB-MATNR
                   AND   WERKS EQ I_MCHB-WERKS
                   AND   LGORT EQ I_MCHB-LGORT.
    At present the program is taking 3 to 4 hrs in back ground .
    The table is complete table scan using index
    MSEG~M.
    Please suggest to improve the performance of this
    many many thanks
    deepak

    The benchmark should be the join, and I can not see how any of your solutions can be faster than the join
    SELECT   .....
                  INTO TABLE  ....
                  UP TO 1 ROWS
                  FROM mchb as a
                  INNER JOIN mseg as b
                  ON    amatnr EQ bmatnr
                  AND  awerks  EQ bwerks
                  AND  algort    EQ blgort
                  And   acharg  EQ bcharg
                  WHERE a~ ....
    The WHERE condition must come from the select on MCHB, the field list from the total results
    you want.
    If you want to compare, must compare your solutions plus the select to fill I_MCHB.
    Siegfried
    Edited by: Siegfried Boes  on Dec 20, 2007 2:28 PM

  • Performance tunning for select statements using likp lips and vbrp

    Dear all,
      I have a report where i am using select statements using first on likp the for all entries of likp  i am taking data from lips and then for all entries in lips i am taking data from vbrp by matching VGBEL and VGPOS. Now the problem is that when it fetches data from vbrp it is taking lot of time around 13mins. to fetch data from vbrp. How can i overcome the problem.
    regards
    Amit

    Hi,
    there is also no secondary index for preceding document in VBFA table.
    You will also have to create it here.
    Regards,
    Przemysław

  • How to get the values of an Array using JSP Tags

    Hey guys,
    I need some help. I've splited a String using
    fn:split(String, delim) where String = "1,2,3,4" and delim is ,
    This method returns an Array of splited Strings. how do i get the values from this array using jsp tags. I don't wanna put java code to achive that.
    Any help would be highly appreciated
    Thanks

    The JSTL forEach tag.
    In fact if all you want to do is iterate over the comma separated list, the forEach tag supports that without having to use the split function.
    <c:set var="list" value="1,2,3,4"/>
    <c:forEach var="num" items="${list}">
      <c:out value="${num}"/>
    </c:forEach>The c:forTokens method will let you do this with delimiters other than a comma, but the forEach tag works well just with the comma-delimited string.

  • How to get the value from a function using a select statement

    I have a function(user defined not built in) that returns multiple values(like an array). My question is how do i get those values in a select statement. when i tried to retrieve it,
    select pack.my_members from dual;
    i am getting an error
    ORA-00902: invalid datatype
    I am sure this must be a syntax error with the select statement
    The following is the function that give the array of data
    package pack
    package spec
    Type my_table is table of varchar2(25);
    function the_members
    return pack.my_table;
    pakcage body
    function the_members return pack.my_table
    Remarks: This function returns a table containing names of the
    members
    is
    tm pack.my_table:= pack.my_table('first member','second member','third member','fourth member');
    begin
    return tm;
    end the_members;

    Check this example on Pipelinedfunction

Maybe you are looking for

  • Can't run FW CS3! "Licensing for this product has stopped working."

    I purchased and downloaded FW CS3 this morning. I received my serial number and once the file had completed downloading I ran the installer. Everything seems to be working fine, and the install finished without a hitch. I then tried to open the appli

  • I have CS5 master collection and it is now saying invalid serial number

    i have CS5 creative suite. I purchased a year ago have not had any issues, until now, none of my serial numbers are working. Saying they are invalid. Save for the upgrades which I do not have on my computer.

  • How to get absolute path of current directory?

    Hi, everyone! I want to get the absolute path of current directory. Are there some APIs that I can use? Thanks in advance, George

  • Shrink Log File on High Availability

    Dear support good day for you, i using SQL server 2012 and using AlwaysON High Availability (server_SQL1 = Primary & Server_SQL2=Secondary), when i try to shrink the log files he told me you must alter the database to simple recovery mode first but i

  • HT1338 upgrade to mac os 10.7.5

    Hi, I am trying to update my Macbook pro software to Mac OS X 10.7.5. I did software update and it tells me that my mac is uptodate. The reason that I want to do this is because My iPhoto update from app store is not downloading because my mac is not