Selecting records from DB table with out using internal tables

hi,
i need to retrieve values from a database table based on few fields and date as well. however, i need to check whether the date is less or equal to the current date and along with that i should get the appropriate record. how can i do that with out using internal table.
field1-----date---
11111----
20070219
11111--20070214 <---
11111----
20070205
in the above scenario i should get the second record
Regards,
Kranthi.

Try:
REPORT ztest MESSAGE-ID 00.
TABLES bkpf.
SELECT * FROM bkpf
  UP TO 1 ROWS
  WHERE budat <= sy-datum
  ORDER BY budat DESCENDING.
ENDSELECT.
Rob

Similar Messages

  • Last 10 records of a table with out using count

    How can i get last 10 records of a table with out using count() method? if there is some page size(eg 10) , and if we want last page. is it posible without ount()? if posible how?
    Message was edited by:
    user480375

    "is there any other way without nesting?"
    Not correctly, no. What is your problem with nesting? Nested queries are not inherently slower than unnested queries. In some cases, such as this, they are the only correct way to do the query. Even an analytic version of the Top N needs to be nested because:
    SQL> SELECT object_name
      2  FROM t
      3  WHERE ROW_NUMBER() OVER (ORDER BY object_name DESC) < 11
      4  /
    WHERE ROW_NUMBER() OVER (ORDER BY object_name DESC) < 11
    ERROR at line 3:
    ORA-30483: window  functions are not allowed hereTTFN
    John

  • Deletion of duplicates in the table with out using rowid

    How can I delete duplicates in the table with out using ROWID .

    hi
    sleect count(coulmnname),columnname from table
    group by columnname
    having count(columnname) > 1;
    find the primary key of the table
    apply the below query
    delete from table
    where (primary key,repeated column name )
    not in
    ( select min(primary key), repeated column
    from employee group by repeated column );
    use this in the primary key column use empid ,,,the repated column is ename
    empid ename
    1 sankar
    2 sankar
    try this one

  • How to fetch the data to the internal table with out using mandt

    Hi all,
    Iam giving my code please observer... and give me the reasonable solution.
      t_mar LIKE STANDARD TABLE OF z_mar.
    SELECT  mandt
             werks                         " Plant
             lifnr                         " Vendor
        FROM z_mar
        INTO TABLE t_mar
    where sal = 2000.
    By removing MANDT from select query, it is going to dump.
    ex:
       SELECT 
              werks                         " Plant
              lifnr                         " Vendor
         FROM z_mar
         INTO TABLE t_mar
    where sal = 2000.
    > Now it is going to dump ( here i removed the mandt field ).
    Please give me a solution to fetch the data by removing mandt in select statement, with out chaning the internal table structure.
    Thanks,
    Ravi

    hi Ravi,
    i also had to avoid move-corresponding and the following is what i did...its extra work and goes around but it will
    do the needed work..............
    t_mar LIKE STANDARD TABLE OF z_mar.
    SELECT *
    FROM z_mar
    INTO TABLE t_mar
    where sal = 2000.
    the above gets you all the fields ...but if you still want to narrow it down to just two fields
    *****Declaring structure with 2 fields
    data:begin of fs_data.
    data:werks type z_mar-werks,
         lifnr type z_mar-lifnr ,
    data:end of fs_data.
    *******internal table of above
    data:int_data like fs_data occurs 0 with headerline.
    *****moving the only 2 required fields
    loop at t_mar.
    t_mar-werks  = int_data-werks.
    t_mar-lifnr  = int_data-lifnr.
    append int_data.
    endloop.
    Hope you found it useful...
    Regards
    Bx

  • Delete record from fileld symbol which is an internal table

    Hello experts,
    My requirement is like below.....
    Loop at <fs_table> into <fs_wa>.
    if condtion.
    delete record.
    endif.
    endloop.
    I need to delete the field-symbol (an internal table) record.
    any suggestions .......... <<text removed by moderator>>
    Thnanks in advance.
    Zak.
    Edited by: Matt on Nov 18, 2008 4:48 PM Do not offer to reward

    Hi,
    Simply do this
    TABLES : vbap, ekko, ekpo.
    data : it_vbap type table of vbap.
    field-symbols : <fs> type standard table,
                    <fs_wa> like vbap.
    SELECT-OPTIONS : s_vbeln  FOR vbap-vbeln MODIF ID vbe,
                     s_posnr  FOR vbap-posnr MODIF ID vbe.
    select * from vbap into table it_vbap.
    assign it_vbap to <fs>.
    loop at <fs> assigning <fs_wa>.
    delete <fs>.
    endloop.
    Inside the loop you just need to specify the field symbol that points to the table , so the current line will be deleted. Because while looping, the <fs> points to the content of the current line of table it_vbap.
    regards,
    Advait
    Edited by: Advait Gode on Nov 18, 2008 4:17 PM

  • How to update database table with this new internal table

    hi
    i have a internal table having 8 records and it contains one record which was modified by user
    not i want this new record to be updated to the database table which was modified by the user
    how to do it pls suggest?
    i want to use index for comarision as using index will not have any problems like promary key etc
    like i want to capture the index for this table which was modified thr recoed index and use thi record indext to modify the database table
    or any other suggestion
    regards
    nishant

    Hi Nishant,
    Have an additional field in a table to indicate a change with which you avoid in updating the record modified by user.
    Regards,
    Madhu.

  • Is it possibe to delete music from my ipad with out using itunes?

    my ipad wont sync with itunes without a factory restore and all i want to get rid of is some music. so...

    At the moment you need a computer to remove music, I'm not sure what iOS 5 will allow us to do

  • Download only selected record from ALV

    Hi
      I want to download only selected records from ALV output with button.
    i hav to fix the button on ALV screen using &ZDL whenever user presses the button record should be downloaded.
    Pl with coding
    its very very urgent.

    Hi ,
    i dont have the exact code which suits to your requirement
    but declare the internal table
    like
    data: begin of itab occurs 0,
      check type c,
    fields
    end of itab.
    while filling the field catalog
    fieldcatalog-checkbox = 'X'
    for this check field.
    and display the grid
    now write this subroutine
    *&      Form  USER_COMMAND
          Called from within the ALV processes. Currently, '&IC1' is used
          to process the hotspot and display the document 'picked' by the
          user.
          PV_UCOMM    contains the sy-ucomm from ALV
          SELFIELD is a structure that contains all the data required to
                   process a user selection. The following is an example
                   of the SELFIELD structure and sample values:
    FORM USER_COMMAND USING PV_UCOMM LIKE SY-UCOMM
                            SELFIELD TYPE SLIS_SELFIELD.
      CASE PV_UCOMM.
        WHEN '&IC1'.
          loop at itab where check = 'X'.
    append all these records to another internal table itab1
         endloop.
    call function gui_download.
    pass the internal table itab1 in the tables statement
    and also you have to give the file path that may be static or dynamic
    if dynamic you have to call the function module
    f4_filename
    and get the filename and pass the same value to gui_download
    that will be download to the above said path
    endcase.
    end form.
    reward points if helpful,
    thanks & regards,
    venkatesh

  • Analytical reports with out using BI poss ?

    Hi,
    Got a query
    Can we develop any analytical reports on portal which access the data directly from R/3 with out using BI. And it will provide the front end report as it has been already designed.?
    Cheers
    *RAJ*

    Hi,
    You can also use a Character variable as a msg as follows;
    Data : lv_msgtxt(100) type C.
    Concatenate 'Email not found for vendor' ':' gv_lifnr into lv_msgtxt Separated by space.
    Message lv_msgtxt Type 'S'.
    Regards
    Karthik D

  • Problem selecting records from multiple tables

    Good day
    I am writing  a report showing actual vs budget amount per period.  The actual amounts are in one table and the budget amount are in another table.  In this example it is for vehicle sales.  The problem is that in the budget table, there are no records for a particular make if it was not budgeted to make a sale.  If I try to get the records using the select expert it matches the key in actual table with key in budget table and retrieve.  What happens then is that the records in the actual table get excluded if there was not a record for it in the budget table.  How do I then do this selection, i.e. if there is a record in the budget table, then retrieve, otherwise make the budget amount 0?
    Thanks
    Wilhelm

    This is always difficult the best way is to use a command and union the two sets of data.
    First part uses a left outer join from Actual to Budget and brings back all actual data with and without a budget.
    Second parts brings back data from budegt where nothing exists in actual
    select (field list) from
    Actual a
    left outer join Budget b on a.field = b.field
    where (any other filter condition)
    union all
    select (field list) from
    budget b
    left outer join actual a on b.field = a.field and a.field is null
    where (any other filter condition)
    You can get the first query from your current report and the modify to build the second unioned query.
    Ian

  • Performance problem with selecting records from BSEG and KONV

    Hi,
    I am having performance problem while  selecting records from BSEG and KONV table. As these two tables have large amount of data , they are taking lot of time . Can anyone help me in improving the performance . Thanks in advance .
    Regards,
    Prashant

    Hi,
    Some steps to improve performance
    SOME STEPS USED TO IMPROVE UR PERFORMANCE:
    1. Avoid using SELECT...ENDSELECT... construct and use SELECT ... INTO TABLE.
    2. Use WHERE clause in your SELECT statement to restrict the volume of data retrieved.
    3. Design your Query to Use as much index fields as possible from left to right in your WHERE statement
    4. Use FOR ALL ENTRIES in your SELECT statement to retrieve the matching records at one shot.
    5. Avoid using nested SELECT statement SELECT within LOOPs.
    6. Avoid using INTO CORRESPONDING FIELDS OF TABLE. Instead use INTO TABLE.
    7. Avoid using SELECT * and Select only the required fields from the table.
    8. Avoid nested loops when working with large internal tables.
    9. Use assign instead of into in LOOPs for table types with large work areas
    10. When in doubt call transaction SE30 and use the examples and check your code
    11. Whenever using READ TABLE use BINARY SEARCH addition to speed up the search. Be sure to sort the internal table before binary search. This is a general thumb rule but typically if you are sure that the data in internal table is less than 200 entries you need not do SORT and use BINARY SEARCH since this is an overhead in performance.
    12. Use "CHECK" instead of IF/ENDIF whenever possible.
    13. Use "CASE" instead of IF/ENDIF whenever possible.
    14. Use "MOVE" with individual variable/field moves instead of "MOVE-
    CORRESPONDING" creates more coding but is more effcient.

  • Can i select Records from two tables into an itab.

    Hi,
        Suppose that i have two tables spfli and sflight.
        Now i want the records from both the tables into a single internal table.
        If so please let me know how this can be done.
        itab should consist of all the columns in sflight and spfli.
    Regards,
    Sai

    Sai,
    Yes u can do it using JOINs.
    Use this link for ref
    http://www.sap-img.com/abap/inner-joins.htm
    INNER JOIN results are an intersection of the tables being joined where in only if both the tables havethe data the result is pused onto the result set.
    WHERE as in LEFT OUTR JOIN you can push the data of the LEF T table on the resultset even when the join condition is not met.
    The use is that you wantto have all the data that is there in left table and also the right table if the join condition is a success then right table fileds will have data else they are initial.
    OUTJOIN's are used in MAINTENANNCE VIEWS, HELP VIEWS .
    INNER JOINS are used DATABSE VIEWS.
    Inner Join:-
    SELECT pcarrid pconnid ffldate bbookid
    INTO CORRESPONDING FIELDS OF TABLE itab
    FROM ( ( spfli AS p
    INNER JOIN sflight AS f ON pcarrid = fcarrid AND
    pconnid = fconnid )
    INNER JOIN sbook AS b ON bcarrid = fcarrid AND
    bconnid = fconnid AND
    bfldate = ffldate )
    WHERE p~cityfrom = 'FRANKFURT' AND
    p~cityto = 'NEW YORK' AND
    fseatsmax > fseatsocc.
    Left Outer Join
    SELECT scarrid scarrname p~connid
    INTO CORRESPONDING FIELDS OF TABLE itab
    FROM scarr AS s
    LEFT OUTER JOIN spfli AS p ON scarrid = pcarrid AND
    p~cityfrom = 'FRANKFURT'.
    Reward if helpful,
    Karthik

  • Please suggest a select query / sub query with out using any subprograms or

    source table: Three columns ORIGIN, DESTINATION,MILES
    Origin      Destination Miles
    Sydney      Melbourne      1000
    Perth      Adelaide      3000
    Canberra      Melbounre      700
    Melbourne      Sydney           1000
    Brisbane      Sydney           1000
    Perth      Darwin           4000
    Sydney      Brisbane      1000
    out put :Three columns ORIGIN, DESTINATION,MILES
    Duplicate routes are to be ignored so the output is
    Origin      Destination      Miles
    Sydney      Melbourne      1000
    Perth      Adelaide      3000
    Canberra      Melbounre      700
    Brisbane      Sydney           1000
    Perth      Darwin           4000
    Please suggest a select query / sub query with out using any subprograms or functions/pkgs to get the out put table.

    Hi,
    user9368047 wrote:
    ... Please suggest a select query / sub query with out using any subprograms or functions/pkgs to get the out put table.Why? If the most efficient way to get the results you want involves using a function, why wouldn't you use it?
    Here's one way, without any functions:
    SELECT     a.*
    FROM           source_table  a
    LEFT OUTER JOIN      source_table  b  ON   a.origin          = b.destination
                                          AND  a.destination       = b.origin
                          AND  a.miles          = b.miles
    WHERE   b.origin  > a.origin    -- Not b.origin > b.origin
    OR     b.origin  IS NULL
    ;If you'd care to post CREATE TABLE and INSERT statements for your sample data, then I could test this.
    Edited by: Frank Kulash on Nov 6, 2012 7:39 PM
    Corrected WHERE clause after MLVrown (below)

  • Selecting Records from 125 million record table to insert into smaller table

    Oracle 11g
    I have a large table of 125 million records - t3_universe.  This table never gets updated or altered once loaded,  but holds data that we receive from a lead company.
    I need to select records from this large table that fit certain demographic criteria and insert those into a smaller table - T3_Leads -  that will be updated with regard to when the lead is mailed and for other relevant information.
    My question is what is the best (fastest) approach to select records from this 125 million record table to insert into the smaller table.  I have tried a variety of things - views, materialized views, direct insert into smaller table...I think I am probably missing other approaches.
    My current attempt has been to create a View using the query that selects the records as shown below.  Then use a second query that inserts into T3_Leads from this View V_Market.  This is very slow. Can I just use an Insert Into T3_Leads with this query - it did not seem to work with the WITH clause?    My Index on the large table is t3_universe_composite and includes zip_code, address_key, household_key. 
    CREATE VIEW V_Market  as
    WITH got_pairs    AS  
         SELECT /*+ INDEX_FFS(t3_universe t3_universe_composite) */  l.zip_code, l.zip_plus_4, l.p1_givenname, l.surname, l.address, l.city, l.state, l.household_key, l.hh_type as l_hh_type, l.address_key, l.narrowband_income, l.p1_ms, l.p1_gender, l.p1_exact_age, l.p1_personkey, e.hh_type as filler_data, 1.p1_seq_no, l.p2_seq_no 
         ,      ROW_NUMBER () OVER ( PARTITION BY  l.address_key 
                                      ORDER BY      l.hh_verification_date  DESC 
                      ) AS r_num   
         FROM   t3_universe  e   
         JOIN   t3_universe  l  ON   
                l.address_key  = e.address_key
                AND l.zip_code = e.zip_code
              AND   l.p1_gender != e.p1_gender
                 AND   l.household_key != e.household_key         
                 AND  l.hh_verification_date  >= e.hh_verification_date 
      SELECT  * 
      FROM  got_pairs
      where l_hh_type !=1 and l_hh_type !=2 and filler_data != 1 and filler_data != 2 and zip_code in (select * from M_mansfield_02048) and p1_exact_age BETWEEN 25 and 70 and narrowband_income >= '8' and r_num = 1
    Then
    INSERT INTO T3_leads(zip, zip4, firstname, lastname, address, city, state, household_key, hh_type, address_key, income, relationship_status, gender, age, person_key, filler_data, p1_seq_no, p2_seq_no)
    select zip_code, zip_plus_4, p1_givenname, surname, address, city, state, household_key, l_hh_type, address_key, narrowband_income, p1_ms, p1_gender, p1_exact_age, p1_personkey, filler_data, p1_seq_no, p2_seq_no
    from V_Market;

    I had no trouble creating the view exactly as you posted it.  However, be careful here:
    and zip_code in (select * from M_mansfield_02048)
    You should name the column explicitly rather than select *.  (do you really have separate tables for different zip codes?)
    About the performance, it's hard to tell because you haven't posted anything we can use, like explain plans or traces but simply encapsulating your query into a view is not likely to make it any faster.
    Depending on the size of the subset of rows you're selecting, the /*+ INDEX hint may be doing your more harm than good.

  • I need to stream video from itunes to apple tv with out using my 40gb hd.

    i need to stream video from itunes to apple tv with out using my 40gb apple tv can it be done you see i have a 40gb apple tv and it's full and i still have lots more video (movies) in my itunes can i stream movies from itunes to apple tv with my memory full in apple tv??????????

    Select the iTunes library on your computer from the Sources menu in Apple TV and then you can stream. If streaming is not smooth and your router has a multicast setting, try increasing the multicast bit rate. To return to the synced content on your Apple TV, select the Apple TV logo at the top of the Sources menu.

Maybe you are looking for