Selection of data based on condition

Moderator message - Please respect the 2,500 character maximum when posting. Post only the relevant portions of code
Nothing remains, so locked.
Rob
Edited by: Rob Burbank on Mar 12, 2010 10:56 AM

please pass teh specified portion of the code explaining in detail of the query ..
please use teh code option to look it better
this way
Br,
Vijay

Similar Messages

  • Script to select all layers based on condition?

    Do anyone have a script to select all layers based on either name or color label? Possibly using search but not necessarily?

    If you search this forum you will find script that will process all layers in a document.  You can modify one if them to skip the layers you do not want to process do nothing to the. The process uses recursion to process layers within layer groups,.

  • Select expert: selecting sibling data based on one record's ID

    Hi All,
    Let's presume that I have two tables, company and contact. Contact carries the company ID.
    On my report, I have all contacts grouped by comapnies. (simple, huh!?)
    What I need to do is add a parameter that will allow a user to select an employee (id/name/ whatever, the condition is irrelevant to the question), and the report will display THAT employee, the company the employee works for, as well as all other employees who work for the same company.
    To rephrase, Given the ID of a child, I need to return all siblings.
    The obvious solution is to create a sub report that traverses the relationship up one level, and just pass that value as the linked value to the sub report filtered by parent records.
    Anyone have any clever ideas that preclude the use of a sub report? (or SQL command, or stored procedure)
    In the mean time, I'm using a sub report.
    Thanks,
    -R

    I've come up with a not-so-great work around, that seems to solve my problem.
    The additional part of my question is that I need to be able to do it from two sides of a bizzarely complecated three table relationship. A single sub report solution doesn't work. I was hoping for a more broadly applicable solution that didn't involve a sub report.
    What I've done is created a sub report to pre-process my parameters. In my situation, the detail records that I am interested in actually have two different unrelated parent records.
    So, if someone passes in a child record (other params would be null) then I get his parent record, and supress the rest.
    If someone passes in either parent, the report uses a shared string variable to create a list of records NOT to supress. ie: a list of all records that the parent IS related to.
    because my dataset is relatively small, and not likely to grow significantly, it doesn't present an issue to pull the whole data-set, and supress rather than filter, and because it's being presented in the HTML viewer, I don't have to worry about passing a bunch of data I don't need into the client cache. (not to mention that savvy hacker types can't get into the cached data that's present, but supressed)
    Yet another ugly Crystal workaround by Ryan! Hoorah!

  • Select by Date in where condition ?

    Hi,
    How I can select the records from the table which is less than or equal to acc_period date.
    The following details which are using in the select query.
    Fields are...
    acc_period ..-------------- 2005/08/01
    Date_of_Purchase -----.. 2005/09/30
    Here i want check acc_period field in where cluase.
    select to_char(Date_of_Purchase,'yyyy/mm/dd') from fom_fix_asset_dtl where acc_period< 2005/08/01
    The query is not working..
    How can i give this type of condition in select query.
    pls reply ..
    Thanks

    What is the data type of your acc_period field? If it is varchar2, use this
    select to_char(Date_of_Purchase,'yyyy/mm/dd')
    from fom_fix_asset_dtl
    where to_date(acc_period, 'YYYY/MM/DD')< to_date('2005/08/01', 'YYYY/MM/DD')
    /Cheers
    Sarma.

  • Displaying only the relevant table data based on condition

    Is it possible to display a part of a table based on a condition which is not in that table.
    My example - I am using the spreadsheet to determine the accumulation of $$ in an account over a period of time and then how quickly that would be spent at a designated withdrawal rate.
    However, I only want to display the values that relate to the time frame I specify.
    So in one table I have Personal Data like income, savings, age, interest rate, spending etc.
    In this table I have one column as Age Today and another is Age to stop, then age to Start spending.
    My second tale has all the relevant calculations to accumulate and then withdraw and spend the money.
    What I am looking to do is create and display the relevant portions of the table which refer to the Age Today and Age to Stop.
    Is this possible?

    Hello
    At this time, there is no such a feature in Numbers.
    _Go to "Provide Numbers Feedback" in the "Numbers" menu_, describe what you wish.
    Then, cross your fingers, and wait _at least_ for iWork'09
    Yvan KOENIG (from FRANCE samedi 29 mars 2008 11:05:22)

  • Using SQL Loader to insert data based on conditionally statements

    I would like to use sql loader to insert records from a single text file into an Oracle database table. Sounds easy but the problem is that I need to check the existence of data in another table (Table A) before data can be loaded into Table B.
    Table A has two columns: dept_no (primary key value) and dept_name (char)
    Table B has five columns: emp_no (primary key value), dept_no (foreign key value to Table A), employee (char), job_title (char) and salary (number)
    Text File looks like this:
    Finance Jones President 10000
    HR Smith Admin 2000
    HelpDesk Jenkins Technician 3000
    Problem:
    1. I need sql loader to insert records into Table B by first checking if the first field in the file is in Table A.
    2. If value exists get it's dept_no value.
    3. If value doesn't exist discard record ( I might want to have sql loader insert a new record for this into Table A)
    4. Using value from #2, insert the value in Table B for dept_no column.
    5. Also assign a sequence value for the emp_no value in Table B.
    Any guidance is greatly appreciated.
    Thanks,

    Hello,
    I am not sure this is possible with SQL loader. I would rather use an external table based on your file.
    Then, I would use SQL to load your data into your table, based on your conditions.
    Your request is not very complicated, writing the SQL to do that will be really more simple than trying to do it with SQL loader.
    Hope it will help.
    Regards,
    Sylvie

  • SQL query and Delete the data based on condition

    Hi All,
    I have one requirement like I need to fetch the data from the table, In that table one filed (XXXXX) domain type is STAMP.
    delete the data if the sy-datum ( length 8) is greater than field XXXXX  which has length 14.
    Please suggest me how to delete or fetch the data with the same length.
    I have used below code..but did not work..
    "Concatenate sy-datum '%'  into gv_var1.
    select *
       from DD03l
       into itab
    where XXXX like gv_var1."
    and tried this one as well
    1. DELETE itab WHERE XXXXX GT sy-datum.
    2. DELETE itab WHERE XXXXX GT gv_var1.

    Hi,
    When dates are in different formats you have to always convert them into one common format and then do the checks. Its better to convert the date in the variable into timestamp(using CONVERT DATE statement-look for abapdocu for its usage) and then compare it with the date on database.
    data: gv_var1  TYPE timestamp.
    convert date sy-datum into time stamp gv_var1.
    select *
    from DD03l
    into itab
    where XXXX like gv_var1.
    should work now.
    Hope this helps.
    Shwetha

  • Current & Previous month data based on condition

    Hi All,
             Thanks in advance.
    I have some problem in reporting......
            I have to display curr and pre months data .
    If i give fiscal period as 009.2006 i should display no of contracts for 1_90 , 90_180 based on last adjustment date .
    No.of contracts for  <b>last day</b> of given period- <b><b>last adjustment date</b> <=90 .
    Like i should display for given period and previous period.
    If given period is 009.2006 .last day of this month is 31/12/2005.
    like last day for previous period is 30/12/2005.
    Thanks & Regards,
    Sarada .<b></b><b></b>

    Hi Eugene,
               Here is the code..
    WHEN 'LDAT_PRV'.        " Get last day from the given period.
    IF I_STEP = 2.
        REFRESH E_T_RANGE. CLEAR E_T_RANGE.
        LOOP AT I_T_VAR_RANGE INTO TEST WHERE
          VNAM = 'PRV_PER' and IOBJNM = '0FISCPER'. "Contract Enddt
    CONDENSE TEST-LOW.
        V_GJAHR = TEST-LOW+0(4).
        V_BUPER = TEST-LOW+4(3).
    call function 'LAST_DAY_IN_PERIOD_GET'
           EXPORTING
            I_GJAHR = V_GJAHR
            I_PERIV = 'T1'
            I_POPER = V_BUPER
           IMPORTING
            E_DATE = ENDDT.
    IF SY-SUBRC <> 0.
           MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
           WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
        ELSE.
           CLEAR LS_RA_SID.
           LS_RA_SID-SIGN = 'I'.
           LS_RA_SID-OPT = 'EQ'.
          LS_RA_SID-LOW = ENDDT.
          APPEND LS_RA_SID TO E_T_RANGE.
          EXIT.
       ENDIF.
            EXIT.
        ENDLOOP.
      ENDIF.
    Like i have created for one more variable for given period.
    I need last dates for the given and previous periods....
    Best Regards,
    Shradda

  • Select the record based count condition

    Hi Experts
    I have a table with columns  StateDate,State,Name & Type . For the same date there could be 2 or more rows for the same name .
    I need to retrieve the data from the table only for the name containing single row in the table and state = 'On'
    Please find the Create & Insert Scripts below . Am assuming it needs to be done with a window function and am not yet comfortable with window function .
    CREATE TABLE ItemState
    (StateDate Date,
    State Varchar(3),
    Name Varchar(3),
    Type int)
    INSERT INTO Itemstate (Statedate,State,Name,Type)
    Values ('3/11/2014','On','XYZ',1)
    INSERT INTO Itemstate (Statedate,State,Name,Type)
    Values ('3/11/2014','Off','XYZ',1)
    INSERT INTO Itemstate (Statedate,State,Name,Type)
    Values ('3/11/2014','On','ABC',1)
    INSERT INTO Itemstate (Statedate,State,Name,Type)
    Values ('3/12/2014','Off','CBR',1)
    INSERT INTO Itemstate (Statedate,State,Name,Type)
    Values ('3/12/2014','On','CBR',1)
    INSERT INTO Itemstate (Statedate,State,Name,Type)
    Values ('3/12/2014','On','XYZ',1)
    Expected Result
    StateDate
    State
    Name
    Type
    3/11/2014
    ON
    ABC
    1
    3/12/2014
    ON
    XYZ
    1
    Kindly help
    Thanks
    Priya

    INSERT INTO Itemstate (Statedate,State,Name,Type)
    Values ('3/11/2014','On','XYZ',1)
    INSERT INTO Itemstate (Statedate,State,Name,Type)
    Values ('3/11/2014','Off','XYZ',1)
    INSERT INTO Itemstate (Statedate,State,Name,Type)
    Values ('3/11/2014','On','ABC',1)
    INSERT INTO Itemstate (Statedate,State,Name,Type)
    Values ('3/12/2014','Off','CBR',1)
    INSERT INTO Itemstate (Statedate,State,Name,Type)
    Values ('3/12/2014','On','CBR',1)
    INSERT INTO Itemstate (Statedate,State,Name,Type)
    Values ('3/12/2014','On','XYZ',1)
    again adding this 3 rows 
    INSERT INTO Itemstate (Statedate,State,Name,Type)
    Values ('3/11/2014','On','XYZ',1)
    INSERT INTO Itemstate (Statedate,State,Name,Type)
    Values ('3/11/2014','Off','XYZ',1)
    INSERT INTO Itemstate (Statedate,State,Name,Type)
    Values ('3/11/2014','On','ABC',1)
    SELECT *
    FROM   itemstate order by statedate, name,state
    2014-03-11 On
    ABC 1
    2014-03-11 On
    ABC 1
    2014-03-11 Off
    XYZ 1
    2014-03-11 Off
    XYZ 1
    2014-03-11 On
    XYZ 1
    2014-03-11 On
    XYZ 1
    2014-03-12 Off
    CBR 1
    2014-03-12 On
    CBR 1
    2014-03-12 On
    XYZ 1
    so only xyz on 2014-03-12 will qualify
    WITH test
         AS (SELECT *,
                    row_number()
                      OVER (
                        partition BY statedate, name
                        ORDER BY state ASC) rnasc, 
    count(state)
                      OVER (
                        partition BY statedate, name
                        ORDER BY state desc) rncount
             FROM   itemstate)
    SELECT *
    FROM   test t1  where rnasc = 1 
    and state = 'on' and rncount = 1
    Amish shah
    http://bloq.sqltechie.com

  • ALV - selecting the data based on layout set in selection screen

    Hi,
    I have an ALV report (Custom). I want to give layout selection at selection screen, so the user can create/select/manage layout at the time of selection screen and only these columns will be displayed in the final output. Instead user execute the report for all column and at the end user select the layout. I want this layout at the selection screen level like the standard reports.
    Thanks,

    You can do the following
    When the user clicks on download
    1.Use FM REUSE_ALV_LIST_LAYOUT_INFO_GET / REUSE_ALV_GRID_LAYOUT_INFO_GET to get the Fieldcat (since due to selection of layout on sel screen some columns are disabled. For the columns which have been disabled the resultant Fieldcat from the above FMs would have NO_OUT = 'X'. Delete columns from Fieldcat itab where no_out = 'X'
    2.create a dynamic itab using cl_alv_table_create=>create_dynamic_table( )  passing the above Fieldcat itab, get a handle of new itab
    3.loop over the original itab and fill the new dynamic itab
    hope this helps...

  • Insert data based on condition

    I have 2 tables i need to insert data if total of 2 columns becomes 0.One value is negative and another values is positive.
    desc Crdetail
    acc_no---number(6),
    cr_Dt---date,
    cr_amt---Number(15,3)
    desc dbDetail
    acc_no----number(6),
    db_dt--date,
    db_amt--number(15,3)
    CrData
    acc_no----cr_Dt-------cr_amt
    101------10-aug-09----10
    102------20-aug-09----15
    103---21-aug-09---- -20 Note its -20
    DbData
    101----11-aug-09---- -10 --- Note Its -10
    102------20-aug-09----15
    When i inserting to other table
    the sum of db_amt and cr_amt should be zero then only it should insert.
    rgds
    ramya

    user11243021 wrote:
    Hi Instead of adding new column tot_amt can we use case statment or write a function to check and insert.just declare a variable called tot_amt and it should solve your problem. You can use if or case statement as well but I will not advise you to use a function because it becomes too costly in this case (making call then returning value).
    Rgds.

  • Select Functional Location based on Class

    Hi,
    In a query, I need to select the functional locations (TPLNR) based on class (KLASSE_D) and Functional Location Category(FLTYP) which are defaulted on the selection screen. FLTYP = 'G' and LKASSE_D = 'GT_RETOB'  are the values always defaulted on the selection screen.
    I was hoping to select the data from table IFLOT based on FLTYP and filter it by class later. In PROD system, we have about  7 million records in IFLOT where FLTYP = 'G'.
    Can anybody know a better way to select the data based on these 2 conditions?
    Thanks.

    Hi,
    Normally the way I check for tables is as below,
    Go to the screen or transaction to know the tables then on top menu System select option status
    2. You will get pop-up, select Program screen double click, it will open ABAP editor,
    3. Here on Menu utlities select Display Object List or (CtrlShiftF5) will take you to another screen where on left you can see menu for all the Function modules, Dictionary structures etc. Normally we can find related tables from Dictionary structures.
    For getting exact tables it is always trial and error method. Pass some available data and check what are the required fields how to get dependent entries etc.
    Hope it help's.
    Regards,
    N.Nagaraju
    Edited by: NAGARAJU NANDIPATI on Jan 28, 2011 10:35 AM

  • How to pick the data based on customer number

    Hi All ,
    greets....
    i have a requirement to select  the data based on customer number and then do furthur processing .
    example:
    this is some 10 dcouments in customer nr:v1000
    and 20 documents in customer v2000 in a internal table how to select that,
    thank s in advance.

    thier is an internal table which is having some 1000records.
    and their is 6 customers.
    in which i should pick the data based on customer number.
    how to write a code for that?

  • Conditional Select  - How to retrieve data based on different cond.

    Hi
    I have a requirement to retrieve Equipments for Sales orders. But the selection criteria includes that if an Equipment with a EQTYp = 0 exists, only that record needs to be retrieved. And if no such equipment (Eqtyp = 0) exists, then retrieve any equipment from the Sales Order.
    I have for this reason selected a process as follows:
    First collect all sales orders, collect Equipments for them from SER02 and OBJK. And then look for a EQtyp = 0 equipment for each sales order line item. If no such one is found, then one of the other equipments is selected.
    As the report needs to be run open (without specifying any sales orders) at times, the amount of sales orders that are to be checked becomes huge and so retrieving the equipmets also becomes hectic in my current process.
    So, is there any other way to retrieve this information? or can a select be formulated in such a way that it can decide to pick a EQTYP <> 0  equipment when a EQTYP = 0 equipment is not found.
    Thanks in advance.
    Jr.
    Message was edited by:
            Jr Abaper

    Hi
      Is Equipment is an selection-screen field?
    If so give Equipment value = o and # in the selection-screen while executing?
    If that is not an selection-screen field in the select query in the where condition you can mention Equipment = 0 or
                             equipment # 0.
    This can optimize the code some what.
    Regards,
    Sreeram

  • Fetching check number based on condition in selection screen

    In selection screen there r four fields document no,document date ,company code,fiscal year .
    According to client requirement, I have added check number in selection screen. If I enter  the document no in selection screen , the value (bseg –zuonr) should be retrived  in the field check number. If I press F4 in the check number field , the value zuonr based on condition bschl = 50 should be displayed..
    Now it is working fine in development  system.
    But in production it displays 3 values (bschl = 50, bschl = 40 and bschl = 25.Now I need that it should display a single  value based on posting key bseg -bschl = 50 only.
    my code:
    At selection-screen on value-request for P_ZUONR-low.
    select  ZUONR INTO CORRESPONDING FIELDS OF TABLE VALUE_IT1 from BSEG where BELNR IN S_BELNR and BSCHL = '50'.
    CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST'
        EXPORTING
           retfield        = 'ZUONR'
           dynprofield =  'P_ZUONR'
           dynpprog    = sy-cprog
          dynpnr      = sy-dynnr
           value_org   = 'S'
           TABLES
         value_tab       = VALUE_IT1
         FIELD_TAB              = IG_BSEG
          RETURN_TAB             = RETURN
        EXCEPTIONS
          parameter_error = 1
          no_values_found = 2
          OTHERS          = 3.
      IF sy-subrc <> 0.
        MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
                WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
      ENDIF.
    Thanks in advance.

    Hi,
    You can achieve this using Boolean type transient variable.
    > Create a Boolean type Transient variable in VO
    > Use this transient variable as SPELL like ${oa.<view instance>.<view attribute>}
    and in process for request method of controller class. set the value of this transient variable as true or false based on the condition

Maybe you are looking for